ImagingDataCommons / libdicom

C library for reading DICOM files
https://libdicom.readthedocs.io
MIT License
16 stars 7 forks source link

Ubuntu 20.04 build error in strncpy #14

Closed pieper closed 2 years ago

pieper commented 2 years ago
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -g -Wall -Wformat -Wformat-security -g -Wall -Werror -Wextra -g -O2 -MT src/libdicom_la-dicom-file.lo -MD -MP -MF src/.deps/libdicom_la-dicom-file.Tpo -c src/dicom-file.c  -fPIC -DPIC -o src/.libs/libdicom_la-dicom-file.o
In file included from /usr/include/string.h:495,
                 from src/../lib/utarray.h:32,
                 from src/dicom-file.c:11:
In function ‘strncpy’,
    inlined from ‘read_element_header’ at src/dicom-file.c:270:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 3 equals destination size [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/dicom-file.c: In function ‘read_element’:
src/dicom-file.c:470:17: error: ‘vm’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  470 |                 dcm_log_error("Reading of Data Element failed. "
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  471 |                               "Encountered unexpected Value Multiplicity %d "
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  472 |                               "for Data Element '%08X'.",
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  473 |                               vm, tag);
      |                               ~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:838: src/libdicom_la-dicom-file.lo] Error 1
make[1]: Leaving directory '/home/pieper/libdicom/libdicom-repo'
make: *** [Makefile:580: all] Error 2
hackermd commented 2 years ago

@pieper I think I fixed the issue with 4827eca606b69b800d6021e683bcc8a3b653eb53 and it now builds without errors in an Ubuntu 20.04 container (https://github.com/jcupitt/docker-builds/tree/master/libdicom-ubuntu20.04).

It also passes the tests in the Debian container:

docker build -t libdicom-test .
docker run --rm libdicom-test