summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-06-09 03:38:43 +0000
committerimp <imp@FreeBSD.org>1998-06-09 03:38:43 +0000
commitc530c6747abadfbfd17a453f17fb6f28f550fc7f (patch)
treea55b4aeb1d05d42631525f1922f949034a783d82 /bin
parentced2b136af7264a4ab5675b0bee8e972c23f9ea7 (diff)
downloadFreeBSD-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')
-rw-r--r--bin/cp/utils.c4
-rw-r--r--bin/csh/dir.c8
-rw-r--r--bin/pax/ftree.c6
3 files changed, 8 insertions, 10 deletions
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index b261e38..3ee49f6 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
#endif
static const char rcsid[] =
- "$Id: utils.c,v 1.17 1998/05/06 06:50:25 charnier Exp $";
+ "$Id: utils.c,v 1.18 1998/05/13 07:25:17 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -208,7 +208,7 @@ copy_link(p, exists)
int len;
char link[MAXPATHLEN];
- if ((len = readlink(p->fts_path, link, sizeof(link))) == -1) {
+ if ((len = readlink(p->fts_path, link, sizeof(link) - 1)) == -1) {
warn("readlink: %s", p->fts_path);
return (1);
}
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';
diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c
index 8a264aa..b9f32e3 100644
--- a/bin/pax/ftree.c
+++ b/bin/pax/ftree.c
@@ -40,7 +40,7 @@
static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: ftree.c,v 1.10 1998/05/15 06:27:42 charnier Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -508,14 +508,14 @@ next_file(arcn)
* have to read the symlink path from the file
*/
if ((cnt = readlink(ftent->fts_path, arcn->ln_name,
- PAXPATHLEN)) < 0) {
+ PAXPATHLEN - 1)) < 0) {
sys_warn(1, errno, "Unable to read symlink %s",
ftent->fts_path);
continue;
}
/*
* set link name length, watch out readlink does not
- * allways null terminate the link path
+ * allways NUL terminate the link path
*/
arcn->ln_name[cnt] = '\0';
arcn->ln_nlen = cnt;
OpenPOWER on IntegriCloud