[hackers] [sbase] Fixing zero-bye append in readlink. Thanks, Willem van de Krol || David Galos

From: <git_AT_suckless.org>
Date: Wed, 10 Jul 2013 01:40:52 +0200

commit 7adf4f380a05dd88a61aadfa9c473473e012bbc1
Author: David Galos <galosd83_AT_students.rowan.edu>
Date: Tue Jul 9 19:40:28 2013 -0400

    Fixing zero-bye append in readlink. Thanks, Willem van de Krol

diff --git a/readlink.c b/readlink.c
index 6df74e9..065c05d 100644
--- a/readlink.c
+++ b/readlink.c
_AT_@ -20,6 +20,7 @@ main(int argc, char *argv[])
         char buf[PATH_MAX];
         bool nflag = false;
         bool fflag = false;
+ ssize_t n;
 
         ARGBEGIN {
         case 'f':
_AT_@ -42,8 +43,9 @@ main(int argc, char *argv[])
                 if (realpath(argv[0], buf) == NULL)
                         exit(1);
         } else {
- if (readlink(argv[0], buf, sizeof(buf)) < 0)
+ if ((n = readlink(argv[0], buf, sizeof(buf) - 1)) < 0)
                         exit(1);
+ buf[n] = '
Received on Wed Jul 10 2013 - 01:40:52 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 10 2013 - 01:48:15 CEST