sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 7adf4f380a05dd88a61aadfa9c473473e012bbc1
parent 18712b203227cc60162bfddc2c7165a5ec393135
Author: David Galos <galosd83@students.rowan.edu>
Date:   Tue,  9 Jul 2013 19:40:28 -0400

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

Diffstat:
Mreadlink.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/readlink.c b/readlink.c @@ -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': @@ -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] = '\0'; } printf("%s", buf);