[hackers] [sbase] readlink: Use strlcat() instead of strncat() || sin

From: <git_AT_suckless.org>
Date: Wed, 11 Feb 2015 12:55:27 +0100 (CET)

commit 91b535ceaeea3fd21ee11decbcf419f272b20bb6
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 Wed Feb 11 2015 - 12:55:27 CET

This archive was generated by hypermail 2.3.0 : Wed Feb 11 2015 - 13:00:19 CET