mirror of git://git.suckless.org/sbase
ls: Always leave room for the NULL byte in the link target
Otherwise, if the length of the link target is the same as BUFSIZ, we will try to write past the end of buf.
This commit is contained in:
parent
46ea55a258
commit
573ef00c91
2
ls.c
2
ls.c
|
@ -300,7 +300,7 @@ output(Entry *ent)
|
||||||
printf("%10lu ", (unsigned long)ent->size);
|
printf("%10lu ", (unsigned long)ent->size);
|
||||||
printf("%s %s%s", buf, ent->name, indicator(ent->mode));
|
printf("%s %s%s", buf, ent->name, indicator(ent->mode));
|
||||||
if (S_ISLNK(ent->mode)) {
|
if (S_ISLNK(ent->mode)) {
|
||||||
if ((len = readlink(ent->name, buf, sizeof buf)) < 0)
|
if ((len = readlink(ent->name, buf, sizeof buf - 1)) < 0)
|
||||||
eprintf("readlink %s:", ent->name);
|
eprintf("readlink %s:", ent->name);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
printf(" -> %s%s", buf, indicator(ent->tmode));
|
printf(" -> %s%s", buf, indicator(ent->tmode));
|
||||||
|
|
Loading…
Reference in New Issue