From 7f24a0e64774e6566242f44b0f06ab06607d0c97 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Thu, 10 Nov 2005 16:18:56 +1100 Subject: - (dtucker) [openbsd-compat/{LOTS}] Move the "OPENBSD ORIGINAL" markers to after the copyright notices. Having them at the top next to the CVSIDs guarantees a conflict for each and every sync. --- openbsd-compat/dirname.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'openbsd-compat/dirname.c') diff --git a/openbsd-compat/dirname.c b/openbsd-compat/dirname.c index 25ab34dd6..e2cf81db3 100644 --- a/openbsd-compat/dirname.c +++ b/openbsd-compat/dirname.c @@ -1,5 +1,3 @@ -/* OPENBSD ORIGINAL: lib/libc/gen/dirname.c */ - /* $OpenBSD: dirname.c,v 1.10 2003/06/17 21:56:23 millert Exp $ */ /* @@ -18,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/* OPENBSD ORIGINAL: lib/libc/gen/dirname.c */ + #include "includes.h" #ifndef HAVE_DIRNAME -- cgit v1.2.3 From 8f0d8f8ea2a902c58b19d596c22999db61cf39d2 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Thu, 10 Nov 2005 17:33:00 +1100 Subject: - (dtucker) [openbsd-compat/daemon.c] Update from OpenBSD 1.10 -> 1.13. --- ChangeLog | 3 ++- openbsd-compat/dirname.c | 36 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) (limited to 'openbsd-compat/dirname.c') diff --git a/ChangeLog b/ChangeLog index dc1bb31ec..2eaa822df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,7 @@ - (dtucker) [openbsd-compat/inet_ntop.c] Update from OpenBSD 1.5 -> 1.7. - (dtucker) [openbsd-compat/daemon.c] Update from OpenBSD 1.5 -> 1.6. - (dtucker) [openbsd-compat/strsep.c] Update from OpenBSD 1.5 -> 1.6. + - (dtucker) [openbsd-compat/daemon.c] Update from OpenBSD 1.10 -> 1.13. 20051105 - (djm) OpenBSD CVS Sync @@ -3279,4 +3280,4 @@ - (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu -$Id: ChangeLog,v 1.3979 2005/11/10 06:28:35 dtucker Exp $ +$Id: ChangeLog,v 1.3980 2005/11/10 06:33:00 dtucker Exp $ diff --git a/openbsd-compat/dirname.c b/openbsd-compat/dirname.c index e2cf81db3..30fcb4968 100644 --- a/openbsd-compat/dirname.c +++ b/openbsd-compat/dirname.c @@ -1,7 +1,7 @@ -/* $OpenBSD: dirname.c,v 1.10 2003/06/17 21:56:23 millert Exp $ */ +/* $OpenBSD: dirname.c,v 1.13 2005/08/08 08:05:33 espie Exp $ */ /* - * Copyright (c) 1997 Todd C. Miller + * Copyright (c) 1997, 2004 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,10 +21,6 @@ #include "includes.h" #ifndef HAVE_DIRNAME -#ifndef lint -static char rcsid[] = "$OpenBSD: dirname.c,v 1.10 2003/06/17 21:56:23 millert Exp $"; -#endif /* not lint */ - #include #include #include @@ -32,16 +28,18 @@ static char rcsid[] = "$OpenBSD: dirname.c,v 1.10 2003/06/17 21:56:23 millert Ex char * dirname(const char *path) { - static char bname[MAXPATHLEN]; - register const char *endp; + static char dname[MAXPATHLEN]; + size_t len; + const char *endp; /* Empty or NULL string gets treated as "." */ if (path == NULL || *path == '\0') { - (void)strlcpy(bname, ".", sizeof bname); - return(bname); + dname[0] = '.'; + dname[1] = '\0'; + return (dname); } - /* Strip trailing slashes */ + /* Strip any trailing slashes */ endp = path + strlen(path) - 1; while (endp > path && *endp == '/') endp--; @@ -52,19 +50,23 @@ dirname(const char *path) /* Either the dir is "/" or there are no slashes */ if (endp == path) { - (void)strlcpy(bname, *endp == '/' ? "/" : ".", sizeof bname); - return(bname); + dname[0] = *endp == '/' ? '/' : '.'; + dname[1] = '\0'; + return (dname); } else { + /* Move forward past the separating slashes */ do { endp--; } while (endp > path && *endp == '/'); } - if (endp - path + 2 > sizeof(bname)) { + len = endp - path + 1; + if (len >= sizeof(dname)) { errno = ENAMETOOLONG; - return(NULL); + return (NULL); } - strlcpy(bname, path, endp - path + 2); - return(bname); + memcpy(dname, path, len); + dname[len] = '\0'; + return (dname); } #endif -- cgit v1.2.3