about summary refs log tree commit diff
path: root/stdlib/test-canon.c
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2022-02-21 08:26:06 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2022-02-21 08:26:33 +0530
commit949ad78a189194048df8a253bb31d1d11d919044 (patch)
treec4d2f8a544581a91225839aa8cfd67ddced94028 /stdlib/test-canon.c
parentb98d0bbf747f39770e0caba7e984ce9f8f900330 (diff)
downloadglibc-949ad78a189194048df8a253bb31d1d11d919044.tar.gz
glibc-949ad78a189194048df8a253bb31d1d11d919044.tar.xz
glibc-949ad78a189194048df8a253bb31d1d11d919044.zip
realpath: Do not copy result on failure (BZ #28815)
On failure, the contents of the resolved buffer passed in by the caller
to realpath are undefined.  Do not copy any partial resolution to the
buffer and also do not test resolved contents in test-canon.c.

Resolves: BZ #28815

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'stdlib/test-canon.c')
-rw-r--r--stdlib/test-canon.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/stdlib/test-canon.c b/stdlib/test-canon.c
index 185ccf4f48..2ad1218749 100644
--- a/stdlib/test-canon.c
+++ b/stdlib/test-canon.c
@@ -174,7 +174,9 @@ do_test (int argc, char ** argv)
 	  continue;
 	}
 
-      if (!check_path (buf, tests[i].out ? tests[i].out : tests[i].resolved))
+      /* Only on success verify that buf contains the result too.  */
+      if (result != NULL
+	  && !check_path (buf, tests[i].out ? tests[i].out : tests[i].resolved))
 	{
 	  printf ("%s: flunked test %d (expected resolved `%s', got `%s')\n",
 		  argv[0], i, tests[i].out ? tests[i].out : tests[i].resolved,