diff options
author | imp <imp@FreeBSD.org> | 1998-06-09 03:38:43 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 1998-06-09 03:38:43 +0000 |
commit | c530c6747abadfbfd17a453f17fb6f28f550fc7f (patch) | |
tree | a55b4aeb1d05d42631525f1922f949034a783d82 /bin/csh/dir.c | |
parent | ced2b136af7264a4ab5675b0bee8e972c23f9ea7 (diff) | |
download | FreeBSD-src-c530c6747abadfbfd17a453f17fb6f28f550fc7f.zip FreeBSD-src-c530c6747abadfbfd17a453f17fb6f28f550fc7f.tar.gz |
Make sure we pass the length - 1 to readlink, since it adds its own
NUL at the end of the path.
Inspired by: OpenBSD's changes in this area by theo de raadt
Diffstat (limited to 'bin/csh/dir.c')
-rw-r--r-- | bin/csh/dir.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/bin/csh/dir.c b/bin/csh/dir.c index c9627ab..f3b8b9d 100644 --- a/bin/csh/dir.c +++ b/bin/csh/dir.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93"; #else static const char rcsid[] = - "$Id: dir.c,v 1.6 1997/02/22 14:01:42 peter Exp $"; + "$Id: dir.c,v 1.7 1997/08/07 21:42:05 steve Exp $"; #endif #endif /* not lint */ @@ -705,8 +705,7 @@ dcanon(cp, p) */ *--sp = 0; /* form the pathname for readlink */ if (sp != cp && !adrof(STRignore_symlinks) && - (cc = readlink(short2str(cp), tlink, - sizeof tlink)) >= 0) { + (cc = readlink(short2str(cp), tlink, sizeof(tlink) - 1)) >= 0) { (void) Strcpy(link, str2short(tlink)); link[cc] = '\0'; @@ -790,8 +789,7 @@ dcanon(cp, p) if (sp != cp && adrof(STRchase_symlinks) && !adrof(STRignore_symlinks) && - (cc = readlink(short2str(cp), tlink, - sizeof tlink)) >= 0) { + (cc = readlink(short2str(cp), tlink, sizeof(tlink) - 1)) >= 0) { (void) Strcpy(link, str2short(tlink)); link[cc] = '\0'; |