diff options
author | ngie <ngie@FreeBSD.org> | 2017-05-29 06:15:41 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-05-29 06:15:41 +0000 |
commit | c3f62e31649791ac4f3661d59b9d52155addca27 (patch) | |
tree | 6e97cc7513f09f133b97bc238c8bd86fac09ef1d /contrib/netbsd-tests/lib/libc/gen | |
parent | fd158651c7c30a642413746f92d2843a88658264 (diff) | |
download | FreeBSD-src-c3f62e31649791ac4f3661d59b9d52155addca27.zip FreeBSD-src-c3f62e31649791ac4f3661d59b9d52155addca27.tar.gz |
MFC r318315:
lib/libc/gen/realpath_test: make check result from getcwd(3)
This is being done to avoid dereferencing a NULL pointer via strlcat,
obscuring the underlying issue with the getcwd(3) call.
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/gen')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_realpath.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_realpath.c b/contrib/netbsd-tests/lib/libc/gen/t_realpath.c index d4998c7..dfb360f 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_realpath.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_realpath.c @@ -34,6 +34,9 @@ __RCSID("$NetBSD: t_realpath.c,v 1.2 2012/03/27 07:54:58 njoly Exp $"); #include <sys/param.h> #include <atf-c.h> +#ifdef __FreeBSD__ +#include <errno.h> +#endif #include <fcntl.h> #include <stdio.h> #include <stdlib.h> @@ -122,8 +125,15 @@ ATF_TC_BODY(realpath_symlink, tc) char resb[MAXPATHLEN] = { 0 }; int fd; +#ifdef __FreeBSD__ + ATF_REQUIRE_MSG(getcwd(path, sizeof(path)) != NULL, + "getcwd(path) failed: %s", strerror(errno)); + ATF_REQUIRE_MSG(getcwd(slnk, sizeof(slnk)) != NULL, + "getcwd(slnk) failed: %s", strerror(errno)); +#else (void)getcwd(path, sizeof(path)); (void)getcwd(slnk, sizeof(slnk)); +#endif (void)strlcat(path, "/realpath", sizeof(path)); (void)strlcat(slnk, "/symbolic", sizeof(slnk)); |