From daad39345d707b8adccd421f4509de637c5643b0 Mon Sep 17 00:00:00 2001 From: Karol Babioch Date: Fri, 4 May 2018 15:44:00 +0200 Subject: [PATCH] Make use of PATH_MAX for fullpath Instead of hardcoding the buffer size to 256, using PATH_MAX makes more sense here, since this can be defined differently on different platforms. This is not perfect, though, refer to [1] for some details. In our case it should be good enough. [1]: https://eklitzke.org/path-max-is-tricky --- ykpamcfg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ykpamcfg.c b/ykpamcfg.c index d2ad7b5..fece317 100644 --- a/ykpamcfg.c +++ b/ykpamcfg.c @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -164,8 +165,8 @@ do_add_hmac_chalresp(YK_KEY *yk, uint8_t slot, bool verbose, char *output_dir, u */ if (!output_dir){ - char fullpath[256]; - snprintf(fullpath, 256,"%s/.yubico",p->pw_dir); + char fullpath[PATH_MAX]; + snprintf(fullpath, PATH_MAX, "%s/.yubico", p->pw_dir); //check if directory exists if (stat(fullpath,&st)!=0 ){