Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 May 2017 06:15:41 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r319092 - stable/11/contrib/netbsd-tests/lib/libc/gen
Message-ID:  <201705290615.v4T6Ffuu024534@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Mon May 29 06:15:41 2017
New Revision: 319092
URL: https://svnweb.freebsd.org/changeset/base/319092

Log:
  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.

Modified:
  stable/11/contrib/netbsd-tests/lib/libc/gen/t_realpath.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/lib/libc/gen/t_realpath.c
==============================================================================
--- stable/11/contrib/netbsd-tests/lib/libc/gen/t_realpath.c	Mon May 29 06:15:06 2017	(r319091)
+++ stable/11/contrib/netbsd-tests/lib/libc/gen/t_realpath.c	Mon May 29 06:15:41 2017	(r319092)
@@ -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));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705290615.v4T6Ffuu024534>