From 92339b24893440e94db8f1eb13a371aae7568ad2 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Thu, 21 Aug 2003 16:41:41 +1000 Subject: - (dtucker) [openbsd-compat/realpath.c] strcat -> strlcat, rootd -> needslash to fix check for ENAMETOOLONG (OpenBSD realpath.c rev 1.10). --- ChangeLog | 4 +++- openbsd-compat/realpath.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d94e21b..eba1af41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ searching libraries for it. Fixes build errors on NCR MP-RAS. - (dtucker) [configure.ac] Define STREAMS_PUSH_ACQUIRES_CTTY for NCR MP-RAS and Reliant Unix. Fixes "can't set controlling tty errors". + - (dtucker) [openbsd-compat/realpath.c] strcat -> strlcat, rootd -> needslash + to fix check for ENAMETOOLONG (OpenBSD realpath.c rev 1.10). 20030429 - (djm) Add back radix.o (used by AFS support), after it went missing from @@ -1312,4 +1314,4 @@ save auth method before monitor_reset_key_state(); bugzilla bug #284; ok provos@ -$Id: ChangeLog,v 1.2648.2.4 2003/08/21 06:16:21 dtucker Exp $ +$Id: ChangeLog,v 1.2648.2.5 2003/08/21 06:41:41 dtucker Exp $ diff --git a/openbsd-compat/realpath.c b/openbsd-compat/realpath.c index b9035ca2..a85743d6 100644 --- a/openbsd-compat/realpath.c +++ b/openbsd-compat/realpath.c @@ -32,7 +32,7 @@ #if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: realpath.c,v 1.7 2002/05/24 21:22:37 deraadt Exp $"; +static char *rcsid = "$OpenBSD: realpath.c,v 1.10 2003/08/01 21:04:59 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -62,7 +62,7 @@ char * realpath(const char *path, char *resolved) { struct stat sb; - int fd, n, rootd, serrno = 0; + int fd, n, needslash, serrno = 0; char *p, *q, wbuf[MAXPATHLEN], start[MAXPATHLEN]; int symlinks = 0; @@ -138,18 +138,18 @@ loop: * happens if the last component is empty, or the dirname is root. */ if (resolved[0] == '/' && resolved[1] == '\0') - rootd = 1; + needslash = 0; else - rootd = 0; + needslash = 1; if (*wbuf) { - if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) { + if (strlen(resolved) + strlen(wbuf) + needslash >= MAXPATHLEN) { serrno = ENAMETOOLONG; goto err1; } - if (rootd == 0) - (void)strcat(resolved, "/"); - (void)strcat(resolved, wbuf); + if (needslash) + strlcat(resolved, "/", MAXPATHLEN); + strlcat(resolved, wbuf, MAXPATHLEN); } /* Go back to where we came from. */ -- cgit v1.2.3