commit 3f3e15b31497d59985afb4813396cf9d04aaf68d
parent aed987a9af13b44523012844cc80eae19e591194
Author: sin <sin@2f30.org>
Date: Wed, 11 Feb 2015 11:51:57 +0000
readlink: Use strlcat() instead of strncat()
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/readlink.c b/readlink.c
@@ -57,7 +57,8 @@ main(int argc, char *argv[])
arg[2] = '\0';
} else
arg[0] = '\0';
- strncat(arg, argv[0], PATH_MAX);
+ if (strlcat(arg, argv[0], PATH_MAX) >= PATH_MAX)
+ eprintf("path too long\n");
while ((p = strchr(p, '/'))) {
*p = '\0';
if (!realpath(arg, b)) {
@@ -75,7 +76,8 @@ mdone:
/* drop the extra '/' on root */
lp += (argv[0][0] == '/' &&
lp - arg == 1);
- strncat(b, lp, PATH_MAX);
+ if (strlcat(b, lp, PATH_MAX) >= PATH_MAX)
+ eprintf("path too long\n");
}
}
break;