Module Name: src Committed By: kre Date: Thu Sep 27 00:45:34 UTC 2018
Modified Files: src/lib/libc/gen: dirname.c Log Message: HACK: if calling dirname() with the results of a previous dirname() there is no need to copy the path into the output buffer, it is already there.... All this has to change to become compat with a forthcoming POSIX update. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/dirname.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/gen/dirname.c diff -u src/lib/libc/gen/dirname.c:1.13 src/lib/libc/gen/dirname.c:1.14 --- src/lib/libc/gen/dirname.c:1.13 Wed Jul 16 10:52:26 2014 +++ src/lib/libc/gen/dirname.c Thu Sep 27 00:45:34 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $ */ +/* $NetBSD: dirname.c,v 1.14 2018/09/27 00:45:34 kre Exp $ */ /*- * Copyright (c) 1997, 2002 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $"); +__RCSID("$NetBSD: dirname.c,v 1.14 2018/09/27 00:45:34 kre Exp $"); #endif /* !LIBC_SCCS && !lint */ #include "namespace.h" @@ -83,7 +83,8 @@ xdirname_r(const char *path, char *buf, out: if (buf != NULL && buflen != 0) { buflen = MIN(len, buflen - 1); - memcpy(buf, path, buflen); + if (buf != path) + memcpy(buf, path, buflen); buf[buflen] = '\0'; } return len;