]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tftpd: always use curl's own tftp.h
authorPatrick Monnerat <patrick@monnerat.net>
Wed, 20 Sep 2023 12:02:05 +0000 (14:02 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 21 Sep 2023 06:47:07 +0000 (08:47 +0200)
Using the system's provided arpa/tftp.h and optimizing, GCC 12 detects
and reports a stringop-overread warning:

tftpd.c: In function ‘write_behind.isra’:
tftpd.c:485:12: warning: ‘write’ reading between 1 and 2147483647 bytes from a region of size 0 [-Wstringop-overread]
  485 |     return write(test->ofile, writebuf, count);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from tftpd.c:71:
/usr/include/arpa/tftp.h:58:30: note: source object ‘tu_data’ of size 0
   58 |                         char tu_data[0];        /* data or error string */
      |                              ^~~~~~~

This occurs because writebuf points to this field and the latter
cannot be considered as being of dynamic length because it is not
the last field in the structure. Thus it is bound to its declared
size.

This commit always uses curl's own version of tftp.h where the
target field is last in its structure, effectively avoiding the
warning.

As HAVE_ARPA_TFTP_H is not used anymore, cmake/configure checks for
arpa/tftp.h are removed.

Closes #11897

CMake/Platforms/WindowsCache.cmake
CMakeLists.txt
configure.ac
lib/curl_config.h.cmake
tests/server/tftpd.c

index 44a1fc96995ee14af441c5b655ce12af0748a70f..6a8756623f3d7cad955b362d3caaa4068f2837b7 100644 (file)
@@ -53,7 +53,6 @@ if(NOT UNIX)
     set(HAVE_LIBZ 0)
 
     set(HAVE_ARPA_INET_H 0)
-    set(HAVE_ARPA_TFTP_H 0)
     set(HAVE_FCNTL_H 1)
     set(HAVE_IFADDRS_H 0)
     set(HAVE_IO_H 1)
index 1a2e08d7fdc243e2fdd931c21fd9f5b6e5e7427f..45838483c5705af0baeb9ba2d88bfeb9feb778a7 100644 (file)
@@ -1035,7 +1035,6 @@ check_include_file_concat("sys/un.h"         HAVE_SYS_UN_H)
 check_include_file_concat("sys/utime.h"      HAVE_SYS_UTIME_H)
 check_include_file_concat("sys/xattr.h"      HAVE_SYS_XATTR_H)
 check_include_file_concat("arpa/inet.h"      HAVE_ARPA_INET_H)
-check_include_file_concat("arpa/tftp.h"      HAVE_ARPA_TFTP_H)
 check_include_file_concat("fcntl.h"          HAVE_FCNTL_H)
 check_include_file_concat("idn2.h"           HAVE_IDN2_H)
 check_include_file_concat("ifaddrs.h"        HAVE_IFADDRS_H)
index 15fbda12adc85ce15ad285331d1947eb15e3df9d..a2c8e2ee3a696556e954903bae3eed8e057e04df 100644 (file)
@@ -3443,7 +3443,6 @@ AC_CHECK_HEADERS(
         libgen.h \
         locale.h \
         stdbool.h \
-        arpa/tftp.h \
         sys/filio.h \
         sys/wait.h \
         setjmp.h,
index 65901a2b1dd2df70a7d138c2ae7608722de85150..328a77d733ee708c6590a91796feadc755ae8bf7 100644 (file)
 /* Define to 1 if you have the <arpa/inet.h> header file. */
 #cmakedefine HAVE_ARPA_INET_H 1
 
-/* Define to 1 if you have the <arpa/tftp.h> header file. */
-#cmakedefine HAVE_ARPA_TFTP_H 1
-
 /* Define to 1 if you have _Atomic support. */
 #cmakedefine HAVE_ATOMIC 1
 
index 8bcd452d047297d31732fd249406766b4ad2207d..8db82ff2331bf753b0e3062b35edabea9d4542b2 100644 (file)
 #ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
 #endif
-#ifdef HAVE_ARPA_TFTP_H
-#include <arpa/tftp.h>
-#else
-#include "tftp.h"
-#endif
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
@@ -97,6 +92,7 @@
 #include "getpart.h"
 #include "util.h"
 #include "server_sockaddr.h"
+#include "tftp.h"
 
 /* include memdebug.h last */
 #include "memdebug.h"