Opened 5 months ago

Last modified 5 months ago

#68934 assigned defect

icu-devel: -Wformat-truncation= warnings on 32-bit

Reported by: barracuda156 Owned by: catap (Kirill A. Korinsky)
Priority: Low Milestone:
Component: ports Version: 2.8.1
Keywords: Cc:
Port: icu-devel

Description

Is this something of a concern?

/opt/local/bin/g++-mp-13 -DU_ATTRIBUTE_DEPRECATED= -DUDATA_SO_SUFFIX=\".dylib\" -DSTATIC_O=\"ao\" -DU_HAVE_STRTOD_L=1 -DU_HAVE_XLOCALE_H=1 -I. -I../../common -I./../toolutil -pipe -Os -D_GLIBCXX_USE_CXX11_ABI=0 -arch ppc -W -Wall -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long -std=c++11 -fno-common -c -MMD -MT "pkgdata.d pkgdata.o pkgdata.ao" -o pkgdata.o pkgdata.cpp
/opt/local/bin/gcc-mp-13 -DU_ATTRIBUTE_DEPRECATED= -DUDATA_SO_SUFFIX=\".dylib\" -DSTATIC_O=\"ao\" -DU_HAVE_STRTOD_L=1 -DU_HAVE_XLOCALE_H=1 -I. -I../../common -I./../toolutil -pipe -Os -arch ppc -std=c11 -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -fno-common -c -MMD -MT "pkgtypes.d pkgtypes.o pkgtypes.ao" -o pkgtypes.o pkgtypes.c
cd ../.. \
	 && CONFIG_FILES=tools/pkgdata/pkgdata.1 CONFIG_HEADERS= /bin/sh ./config.status
config.status: creating tools/pkgdata/pkgdata.1
pkgdata.cpp: In function 'int32_t pkg_createWithoutAssemblyCode(UPKGOptions*, const char*, char)':
pkgdata.cpp:1706:33: warning: '%s' directive output may be truncated writing up to 511 bytes into a region of size between 422 and 511 [-Wformat-truncation=]
 1706 |                             "%s_%s",
      |                                 ^~
 1707 |                             DATA_PREFIX[n],
 1708 |                             newNameTmp);
      |                             ~~~~~~~~~~
pkgdata.cpp:1704:40: note: 'snprintf' output between 2 and 602 bytes into a destination of size 512
 1704 |                     auto ret = snprintf(newName,
      |                                ~~~~~~~~^~~~~~~~~
 1705 |                             sizeof(newName),
      |                             ~~~~~~~~~~~~~~~~
 1706 |                             "%s_%s",
      |                             ~~~~~~~~    
 1707 |                             DATA_PREFIX[n],
      |                             ~~~~~~~~~~~~~~~
 1708 |                             newNameTmp);
      |                             ~~~~~~~~~~~ 
pkgdata.cpp: In function 'int32_t pkg_installLibrary(const char*, const char*, UBool)':
pkgdata.cpp:1141:33: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 247 and 502 [-Wformat-truncation=]
 1141 |             "cd %s && %s %s %s%s%s",
      |                                 ^~
......
 1145 |             installDir, PKGDATA_FILE_SEP_STRING, libFileNames[LIB_FILE_VERSION]);
      |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp:1139:24: note: 'snprintf' output 11 or more bytes (assuming 521) into a destination of size 512
 1139 |     auto ret = snprintf(cmd,
      |                ~~~~~~~~^~~~~
 1140 |             sizeof(cmd),
      |             ~~~~~~~~~~~~
 1141 |             "cd %s && %s %s %s%s%s",
      |             ~~~~~~~~~~~~~~~~~~~~~~~~
 1142 |             targetDir,
      |             ~~~~~~~~~~  
 1143 |             pkgDataFlags[INSTALL_CMD],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~
 1144 |             libFileNames[LIB_FILE_VERSION],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1145 |             installDir, PKGDATA_FILE_SEP_STRING, libFileNames[LIB_FILE_VERSION]);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:986:109: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
  986 |             snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
      |                                                                                                             ^
In function 'void createFileNames(UPKGOptions*, char, const char*, const char*, const char*, UBool, UBool)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:691:28:
pkgdata.cpp:986:21: note: 'snprintf' output 1 or more bytes (assuming 257) into a destination of size 256
  986 |             snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  987 |                     libFileNames[LIB_FILE],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~
  988 |                     FILE_SUFFIX,
      |                     ~~~~~~~~~~~~
  989 |                     pkgDataFlags[SOBJ_EXT]);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:991:109: warning: '%s' directive output may be truncated writing up to 1 bytes into a region of size between 0 and 256 [-Wformat-truncation=]
  991 |             snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s%s%s",
      |                                                                                                             ^~
In function 'void createFileNames(UPKGOptions*, char, const char*, const char*, const char*, UBool, UBool)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:691:28:
pkgdata.cpp:991:21: note: 'snprintf' output between 1 and 258 bytes into a destination of size 256
  991 |             snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s%s%s",
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  992 |                     libFileNames[LIB_FILE],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~
  993 |                     FILE_SUFFIX,
      |                     ~~~~~~~~~~~~
  994 |                     reverseExt ? version : pkgDataFlags[SOBJ_EXT],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  995 |                     FILE_EXTENSION_SEP,
      |                     ~~~~~~~~~~~~~~~~~~~
  996 |                     reverseExt ? pkgDataFlags[SOBJ_EXT] : version);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:1010:111: warning: '%s' directive output may be truncated writing up to 9 bytes into a region of size between 0 and 256 [-Wformat-truncation=]
 1010 |             snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_MAJOR]), "%s%s%s%s%s",
      |                                                                                                               ^~
In function 'void createFileNames(UPKGOptions*, char, const char*, const char*, const char*, UBool, UBool)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:691:28:
pkgdata.cpp:1010:21: note: 'snprintf' output between 1 and 276 bytes into a destination of size 256
 1010 |             snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_MAJOR]), "%s%s%s%s%s",
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1011 |                     libFileNames[LIB_FILE],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~
 1012 |                     FILE_SUFFIX,
      |                     ~~~~~~~~~~~~
 1013 |                     reverseExt ? version_major : pkgDataFlags[SO_EXT],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1014 |                     FILE_EXTENSION_SEP,
      |                     ~~~~~~~~~~~~~~~~~~~
 1015 |                     reverseExt ? pkgDataFlags[SO_EXT] : version_major);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:1017:101: warning: '%s' directive output may be truncated writing up to 1 bytes into a region of size between 0 and 256 [-Wformat-truncation=]
 1017 |             snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s%s%s",
      |                                                                                                     ^~
In function 'void createFileNames(UPKGOptions*, char, const char*, const char*, const char*, UBool, UBool)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:691:28:
pkgdata.cpp:1017:21: note: 'snprintf' output between 1 and 258 bytes into a destination of size 256
 1017 |             snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s%s%s",
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1018 |                     libFileNames[LIB_FILE],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~
 1019 |                     FILE_SUFFIX,
      |                     ~~~~~~~~~~~~
 1020 |                     reverseExt ? version : pkgDataFlags[SO_EXT],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1021 |                     FILE_EXTENSION_SEP,
      |                     ~~~~~~~~~~~~~~~~~~~
 1022 |                     reverseExt ? pkgDataFlags[SO_EXT] : version);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:1000:111: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
 1000 |             snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
      |                                                                                                               ^
In function 'void createFileNames(UPKGOptions*, char, const char*, const char*, const char*, UBool, UBool)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:691:28:
pkgdata.cpp:1000:21: note: 'snprintf' output 1 or more bytes (assuming 257) into a destination of size 256
 1000 |             snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1001 |                     libFileNames[LIB_FILE],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~
 1002 |                     FILE_SUFFIX,
      |                     ~~~~~~~~~~~~
 1003 |                     pkgDataFlags[SO_EXT]);
      |                     ~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:1005:101: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
 1005 |             snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s",
      |                                                                                                     ^
In function 'void createFileNames(UPKGOptions*, char, const char*, const char*, const char*, UBool, UBool)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:691:28:
pkgdata.cpp:1005:21: note: 'snprintf' output 1 or more bytes (assuming 257) into a destination of size 256
 1005 |             snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s",
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1006 |                     libFileNames[LIB_FILE],
      |                     ~~~~~~~~~~~~~~~~~~~~~~~
 1007 |                     FILE_SUFFIX,
      |                     ~~~~~~~~~~~~
 1008 |                     pkgDataFlags[SO_EXT]);
      |                     ~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:1035:100: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
 1035 |             snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s.%s", libFileNames[LIB_FILE], pkgDataFlags[A_EXT]);
      |                                                                                                    ^
In function 'void createFileNames(UPKGOptions*, char, const char*, const char*, const char*, UBool, UBool)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:691:28:
pkgdata.cpp:1035:21: note: 'snprintf' output 2 or more bytes (assuming 257) into a destination of size 256
 1035 |             snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s.%s", libFileNames[LIB_FILE], pkgDataFlags[A_EXT]);
      |             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:1314:97: warning: '.' directive output may be truncated writing 1 byte into a region of size between 0 and 256 [-Wformat-truncation=]
 1314 |         snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s.%s",
      |                                                                                                 ^
In function 'int32_t pkg_archiveLibrary(const char*, const char*, UBool)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:809:44:
pkgdata.cpp:1314:17: note: 'snprintf' output 2 or more bytes (assuming 258) into a destination of size 256
 1314 |         snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s.%s",
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1315 |                 libFileNames[LIB_FILE],
      |                 ~~~~~~~~~~~~~~~~~~~~~~~
 1316 |                 pkgDataFlags[LIB_EXT_ORDER][0] == '.' ? "." : "",
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1317 |                 reverseExt ? version : pkgDataFlags[SO_EXT],
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1318 |                 reverseExt ? pkgDataFlags[SO_EXT] : version);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:1220:36: warning: '%s' directive output may be truncated writing up to 2047 bytes into a region of size 511 [-Wformat-truncation=]
  656 |                 result = pkg_installCommonMode(o->install, targetFileNamePath);
      |                                                            ~~~~~~~~~~~~~~~~~~
......
 1220 |     snprintf(cmd, sizeof(cmd), "%s %s %s", pkgDataFlags[INSTALL_CMD], fileName, installDir);
      |                                    ^~
In function 'int32_t pkg_installCommonMode(const char*, const char*)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:656:47:
pkgdata.cpp:1220:13: note: 'snprintf' output 3 or more bytes (assuming 2050) into a destination of size 512
 1220 |     snprintf(cmd, sizeof(cmd), "%s %s %s", pkgDataFlags[INSTALL_CMD], fileName, installDir);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkgdata.cpp: In function 'int32_t pkg_executeOptions(UPKGOptions*)':
pkgdata.cpp:1267:33: warning: '%s' directive output may be truncated writing up to 511 bytes into a region of size 510 [-Wformat-truncation=]
 1267 |                         "%s %s%s%s %s%s%s",
      |                                 ^~
 1268 |                         pkgDataFlags[INSTALL_CMD],
 1269 |                         srcDir, PKGDATA_FILE_SEP_STRING, buffer,
      |                                                          ~~~~~~
In function 'int32_t pkg_installFileMode(const char*, const char*, const char*)',
    inlined from 'int32_t pkg_executeOptions(UPKGOptions*)' at pkgdata.cpp:596:41:
pkgdata.cpp:1265:36: note: 'snprintf' output 5 or more bytes (assuming 1538) into a destination of size 512
 1265 |                 auto ret = snprintf(cmd,
      |                            ~~~~~~~~^~~~~
 1266 |                         sizeof(cmd),
      |                         ~~~~~~~~~~~~
 1267 |                         "%s %s%s%s %s%s%s",
      |                         ~~~~~~~~~~~~~~~~~~~
 1268 |                         pkgDataFlags[INSTALL_CMD],
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~
 1269 |                         srcDir, PKGDATA_FILE_SEP_STRING, buffer,
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1270 |                         installDir, PKGDATA_FILE_SEP_STRING, buffer);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Low-priority since the build still succeeds.

Change History (3)

comment:1 Changed 5 months ago by catap (Kirill A. Korinsky)

Seems like memory corruption and I suggest to open an issue at upstream

comment:2 in reply to:  1 Changed 5 months ago by barracuda156

Replying to catap:

Seems like memory corruption and I suggest to open an issue at upstream

https://unicode-org.atlassian.net/browse/ICU-22617

comment:3 in reply to:  1 Changed 5 months ago by catap (Kirill A. Korinsky)

Replying to catap:

Seems like memory corruption and I suggest to open an issue at upstream

I was quite wrong: simple warning about wrong type formating. I assume it had been built and works on your machine?

Note: See TracTickets for help on using tickets.