[hackers] [sbase] readlink: Use strlcat() instead of strncat() || sin
commit 3f3e15b31497d59985afb4813396cf9d04aaf68d
Author: sin <sin_AT_2f30.org>
Date: Wed Feb 11 11:51:57 2015 +0000
readlink: Use strlcat() instead of strncat()
diff --git a/readlink.c b/readlink.c
index 1089d06..444e034 100644
--- a/readlink.c
+++ b/readlink.c
_AT_@ -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)) {
_AT_@ -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;
Received on Tue Mar 24 2015 - 23:53:42 CET
This archive was generated by hypermail 2.3.0
: Wed Mar 25 2015 - 00:09:07 CET