Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compat.h:170:46: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] #393

Closed
XVilka opened this issue Jul 19, 2023 · 1 comment
Labels
compile There is a problem compiling libzip.

Comments

@XVilka
Copy link

XVilka commented Jul 19, 2023

Compiler Error

gcc-12 -Isubprojects/libzip-1.10.0/liblibzip.a.p -Isubprojects/libzip-1.10.0 -I../subprojects/libzip-1.10.0 -I../subprojects/libzip-1.10.0/lib -Isubprojects/zlib-1.2.13 -I../subprojects/zlib-1.2.13 -I../subprojects/xz-5.4.3/src/liblzma/api -fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -O2 -g --std=gnu99 -Werror=sizeof-pointer-memaccess -fvisibility=hidden -DASAN=1 -DRZ_ASSERT_STDOUT=1 -Wno-cpp -ftrivial-auto-var-init=pattern -funsigned-char -fPIC -DLZMA_API_STATIC -MD -MQ subprojects/libzip-1.10.0/liblibzip.a.p/lib_zip_dir_add.c.o -MF subprojects/libzip-1.10.0/liblibzip.a.p/lib_zip_dir_add.c.o.d -o subprojects/libzip-1.10.0/liblibzip.a.p/lib_zip_dir_add.c.o -c ../subprojects/libzip-1.10.0/lib/zip_dir_add.c
In file included from ../subprojects/libzip-1.10.0/lib/zipint.h:39,
                 from ../subprojects/libzip-1.10.0/lib/zip_dir_add.c:38:
../subprojects/libzip-1.10.0/lib/zip_dir_add.c: In function ‘zip_dir_add’:
../subprojects/libzip-1.10.0/lib/compat.h:170:46: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
  170 | #define strncpy_s(dest, destsz, src, count) (strncpy((dest), (src), (count)), 0)
      |                                              ^~~~~~~
../subprojects/libzip-1.10.0/lib/zip_dir_add.c:68:15: note: in expansion of macro ‘strncpy_s’
   68 |         (void)strncpy_s(s, len + 2, name, len);
      |               ^~~~~~~~~
../subprojects/libzip-1.10.0/lib/zip_dir_add.c:61:11: note: length computed here
   61 |     len = strlen(name);
      |           ^~~~~~~~~~~~

libzip Version
1.10.0

Operating System and Compiler
Linux x86_64, GCC 12

Additional context

A subproject of rizin

@XVilka XVilka added the compile There is a problem compiling libzip. label Jul 19, 2023
@0-wiz-0
Copy link
Member

0-wiz-0 commented Aug 23, 2023

We have checked the code - it is fine. The warning might be correct in other places, but here it is not.
We suggest not turning on warnings with -Werror if you don't own the code base.

@0-wiz-0 0-wiz-0 closed this as completed Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compile There is a problem compiling libzip.
Projects
None yet
Development

No branches or pull requests

2 participants