xbps/lib
Agustin Chiappe Berrini 2cd0dc688f Fix compilation of initend for gcc 7
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.
2017-08-22 18:35:45 -04:00
..
compat
external libxbps: use xbps_strlc{at,py} everywhere. 2016-04-17 20:17:37 +02:00
fetch Fix compilation in ftp.c 2017-08-22 18:03:32 -04:00
portableproplib lib/portableproplib: fix various oob reads/segfaults 2016-04-07 15:07:11 +02:00
archive.c xbps-create(1): timestamps of metadata files are now set to epoch. 2015-09-03 11:12:49 +02:00
cb_util.c
download.c libxbps: use xbps_strlc{at,py} everywhere. 2016-04-17 20:17:37 +02:00
initend.c Fix compilation of initend for gcc 7 2017-08-22 18:35:45 -04:00
Makefile Implemented reverse conflicts for pkgs in pkgdb and transaction. 2015-10-28 05:23:42 +01:00
package_alternatives.c lib/package_alternatives.c: cleanup create_symlinks 2016-09-05 16:03:41 +02:00
package_config_files.c Fix xbps_dbg_printf arguments by using __attribute__((format, printf)). 2016-02-06 09:13:38 +01:00
package_configure.c lib/package_configure.c: fix memleak 2016-09-25 21:27:46 +02:00
package_find_obsoletes.c Keep /usr/sbin if found as obsolete, it's a symlink in void. 2015-06-05 08:29:05 +02:00
package_fulldeptree.c
package_msg.c
package_orphans.c
package_register.c
package_remove.c package_remove: reset errno when a file does not exist (ENOENT). 2015-12-01 08:31:05 +01:00
package_script.c actually use HAVE_FDATASYNC 2016-02-08 15:09:43 +01:00
package_state.c
package_unpack.c lib/package_unpack.c: add memleak notice 2016-09-25 21:47:58 +02:00
pkgdb_conversion.c
pkgdb.c Fix 29765271e correctly. 2016-03-24 10:23:20 +01:00
plist_fetch.c
plist_find.c Fix 29765271e correctly. 2016-03-24 10:23:20 +01:00
plist_match.c
plist_remove.c
plist.c xbps_array_foreach_cb_multi: handle the case of sysconf returning 0. 2015-11-26 07:18:14 +01:00
proplib_wrapper.c
pubkey2fp.c lib: dont call EVP_cleanup in fp2str 2016-04-24 16:40:25 +02:00
repo_pkgdeps.c Fix xbps_dbg_printf arguments by using __attribute__((format, printf)). 2016-02-06 09:13:38 +01:00
repo_sync.c
repo.c lib/repo: plug stage repo mem leak 2016-05-04 09:46:14 +02:00
rpool.c rpool: if pkg wasn't found set errno to ENOENT. 2015-10-19 17:05:55 +02:00
transaction_commit.c libxbps: initialize locale correctly to handle UTF-8 filenames with musl. 2015-12-11 09:59:16 +01:00
transaction_conflicts.c conflicts: really fix the issue with on hold pkgs and update test case. 2015-11-12 13:23:00 +01:00
transaction_dictionary.c Implemented reverse conflicts for pkgs in pkgdb and transaction. 2015-10-28 05:23:42 +01:00
transaction_ops.c Alternatives framework for xbps (2/2). 2015-10-30 12:24:46 +01:00
transaction_package_replace.c libxbps: extend the fix for #116 even more for the expected case. 2015-10-19 18:19:24 +02:00
transaction_revdeps.c libxbps: remove unused variable `pkgdepname' 2015-10-25 20:03:02 +02:00
transaction_shlibs.c lib/transaction_shlibs.c: fix memleak 2016-09-25 21:47:40 +02:00
transaction_store.c libxbps: print in verbose mode what pkgs are added to the transaction. 2015-09-02 18:56:20 +02:00
util_hash.c lib/util_hash.c: fix memleak. 2016-06-20 10:03:49 +02:00
util.c xbps_symlink_target: fix bug introduced in b81b9ab. 2016-02-04 09:55:46 +01:00
verifysig.c lib/verifysig.c: use xbps_file_hash_raw() 2016-06-16 06:51:10 +02:00