svn commit: r318315 - head/contrib/netbsd-tests/lib/libc/gen

Ngie Cooper ngie at FreeBSD.org
Mon May 15 19:58:03 UTC 2017


Author: ngie
Date: Mon May 15 19:58:01 2017
New Revision: 318315
URL: https://svnweb.freebsd.org/changeset/base/318315

Log:
  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.
  
  MFC after:	2 weeks
  Sponsored by:	Dell EMC Isilon

Modified:
  head/contrib/netbsd-tests/lib/libc/gen/t_realpath.c

Modified: head/contrib/netbsd-tests/lib/libc/gen/t_realpath.c
==============================================================================
--- head/contrib/netbsd-tests/lib/libc/gen/t_realpath.c	Mon May 15 19:32:26 2017	(r318314)
+++ head/contrib/netbsd-tests/lib/libc/gen/t_realpath.c	Mon May 15 19:58:01 2017	(r318315)
@@ -34,6 +34,9 @@ __RCSID("$NetBSD: t_realpath.c,v 1.2 201
 #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));


More information about the svn-src-head mailing list