zip icon indicating copy to clipboard operation
zip copied to clipboard

Error when building the release version with MinGW

Open Limaaron opened this issue 2 years ago • 1 comments

If we build a library:

  1. cmake -G "MinGW Makefiles" -B build
  2. mingw32-make Work!

But if we build:

  1. cmake -G "MinGW Makefiles" -B build -DCMAKE_BUILD_TYPE=Release
  2. mingw32-make It doesn't work :D
W:\Cybegon\zip\src\zip.c: In function 'zip_archive_extract':
W:\Cybegon\zip\src\zip.c:356:5: error: 'strncpy' output may be truncated copying between 0 and 260 bytes from a string of length 511 [-Werror=stringop-truncation]
  356 |     strncpy(&path[dirlen], info.m_filename, MAX_PATH - dirlen);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1.exe: all warnings being treated as errors
mingw32-make[2]: *** [CMakeFiles\zip.dir\build.make:79: CMakeFiles/zip.dir/src/zip.c.obj] Error 1
mingw32-make[2]: Leaving directory 'W:/Cybegon/zip/build'
mingw32-make[1]: *** [CMakeFiles\Makefile2:113: CMakeFiles/zip.dir/all] Error 2
mingw32-make[1]: Leaving directory 'W:/Cybegon/zip/build'
mingw32-make: *** [makefile:148: all] Error 2

MinGW version: GNU 11.2.0 OS: Windows 10

Limaaron avatar Jul 30 '22 04:07 Limaaron

@Limaaron - PTAL if the fix https://github.com/kuba--/zip/pull/273 works for you

kuba-- avatar Aug 02 '22 21:08 kuba--

We can add some if-s for cmake to avoid building with -Werror flag.

WDYT?

kuba-- avatar Aug 05 '22 10:08 kuba--

We can add some if-s for cmake to avoid building with -Werror flag.

WDYT?

it's possible, but I hope there won't be any problems with it. in any case, I will let you know if there is ever a problem with this :)

Limaaron avatar Aug 05 '22 15:08 Limaaron

it's possible, but I hope there won't be any problems with it. in any case, I will let you know if there is ever a problem with this :)

I found the root of the problem

miniz.h

4910: #elif defined(__MINGW32__) || defined(__MINGW64__)
4911: #include <windows.h>
4912: #ifndef MINIZ_NO_TIME
4913: #include <sys/utime.h>
4914: #endif

windows.h -> winbase.h -> fileapi -> miwindef.h -> #define MAX_PATH 260

zip.c

39: #include "miniz.h"
40: #include "zip.h"

this interrupts the definition inside the zip.h MAX_PATH

Limaaron avatar Aug 15 '22 22:08 Limaaron

@Limaaron - PTAL if the fix https://github.com/kuba--/zip/pull/273 works for you

This is not works...

We can add some if-s for cmake to avoid building with -Werror flag.

WDYT?

This is not a solution. Because disable this validation on the release project may add more issues with app ...

EndrII avatar Oct 22 '22 10:10 EndrII