]> git.ipfire.org Git - thirdparty/libarchive.git/commit
Avoid getcwd(0, PATH_MAX) for GNU libc 1529/head
authorOwen W. Taylor <otaylor@fishsoup.net>
Wed, 12 May 2021 20:37:16 +0000 (16:37 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Wed, 12 May 2021 20:44:11 +0000 (16:44 -0400)
commit9a952fe5a25a4fa7d1d7cc1e0c37f08036b29f06
tree289b99befbde70596780f17622e21abc06ba51de
parent942cd1a5e1ce4e1450cecafa2674f71aea0263a4
Avoid getcwd(0, PATH_MAX) for GNU libc

Recent versions of GNU libc and GCC produce a warning on getcwd(0, PATH_MAX):

 test_main.c: In function ‘get_refdir’:
 test_main.c:3684:8: error: argument 1 is null but the corresponding size argument 2 value is 4096 [-Werror=nonnull]
   3684 |  pwd = getcwd(NULL, PATH_MAX);/* Solaris getcwd needs the size. */

This is because getcwd() is marked with the 'write_only (1, 2)' attribute.

Using the alternate getcwd(NULL, 0) path which is supported by GNU libc avoids this.
libarchive/test/test_read_disk_directory_traversals.c
libarchive/test/test_sparse_basic.c
test_utils/test_main.c