2cd0dc688f
This is a trickier situation. The original message: ``` initend.c:423:10: error: ‘%s’ directive output may be truncated writing 15 bytes into a region of size between 1 and 512 [-Werror=format-truncation=] "%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", ^~ initend.c:422:3: note: ‘snprintf’ output between 16 and 527 bytes into a destination of size 512 snprintf(xhp->confdir, sizeof(xhp->confdir), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XBPS_SYSCONF_PATH); ~~~~~~~~~~~~~~~~~~ initend.c:429:7: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation ] "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf); ^~~~~~~ initend.c:428:3: note: ‘snprintf’ output 2 or more bytes (assuming 513) into a destination of size 512 snprintf(xhp->confdir, sizeof(xhp->confdir), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ initend.c:434:9: error: ‘%s’ directive output may be truncated writing 17 bytes into a region of size between 1 and 512 [-Werror=format-truncation=] "%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", ^~ initend.c:433:2: note: ‘snprintf’ output between 18 and 529 bytes into a destination of size 512 snprintf(sysconfdir, sizeof(sysconfdir), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XBPS_SYSDEFCONF_PATH); ~~~~~~~~~~~~~~~~~~~~~ initend.c:455:11: error: ‘%s’ directive output may be truncated writing 14 bytes into a region of size between 0 and 511 [-Werror=format-truncation=] "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", ^~ initend.c:454:3: note: ‘snprintf’ output between 16 and 527 bytes into a destination of size 512 snprintf(xhp->cachedir, sizeof(xhp->cachedir), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XBPS_CACHE_PATH); ~~~~~~~~~~~~~~~~ initend.c:461:7: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation ] "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf); ^~~~~~~ initend.c:460:3: note: ‘snprintf’ output 2 or more bytes (assuming 513) into a destination of size 512 snprintf(xhp->cachedir, sizeof(xhp->cachedir), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ initend.c:467:11: error: ‘%s’ directive output may be truncated writing 12 bytes into a region of size between 0 and 511 [-Werror=format-truncation=] "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", ^~ initend.c:466:3: note: ‘snprintf’ output between 14 and 525 bytes into a destination of size 512 snprintf(xhp->metadir, sizeof(xhp->metadir), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XBPS_META_PATH); ~~~~~~~~~~~~~~~ initend.c:473:7: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation ] "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf); ^~~~~~~ initend.c:472:3: note: ‘snprintf’ output 2 or more bytes (assuming 513) into a destination of size 512 snprintf(xhp->metadir, sizeof(xhp->metadir), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ``` It's basically warning about dangerous operations on strings. And as far as I could tell, is a valid warning and not a false alarm! This fix makes the concept of `XBPS_MAXPATH` lose a little bit of sense as now it doesn't necessarily represent the max size of the paths used by xbps, but instead the max allowed size of the path configured. I think this change is ok, but I wasn't able to find any reference to why it was chosen to be 512. POSIX mandates at least 256, so I'm not breaking anything that wasn't broken already, and Linux seems to have a maximum size of 4096, which is pretty safe. Therefore, this changes should be harmless. I think. |
||
---|---|---|
.. | ||
compat | ||
external | ||
fetch | ||
portableproplib | ||
archive.c | ||
cb_util.c | ||
download.c | ||
initend.c | ||
Makefile | ||
package_alternatives.c | ||
package_config_files.c | ||
package_configure.c | ||
package_find_obsoletes.c | ||
package_fulldeptree.c | ||
package_msg.c | ||
package_orphans.c | ||
package_register.c | ||
package_remove.c | ||
package_script.c | ||
package_state.c | ||
package_unpack.c | ||
pkgdb_conversion.c | ||
pkgdb.c | ||
plist_fetch.c | ||
plist_find.c | ||
plist_match.c | ||
plist_remove.c | ||
plist.c | ||
proplib_wrapper.c | ||
pubkey2fp.c | ||
repo_pkgdeps.c | ||
repo_sync.c | ||
repo.c | ||
rpool.c | ||
transaction_commit.c | ||
transaction_conflicts.c | ||
transaction_dictionary.c | ||
transaction_ops.c | ||
transaction_package_replace.c | ||
transaction_revdeps.c | ||
transaction_shlibs.c | ||
transaction_store.c | ||
util_hash.c | ||
util.c | ||
verifysig.c |