xbps: fix build with gcc-8.2.0

Closes: #1650 [via git-merge-pr]
This commit is contained in:
Jürgen Buchmüller 2018-08-07 08:41:00 +02:00
parent 740cfe1909
commit e40a0d08f7
3 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,42 @@
--- tests/xbps/libxbps/config/main.c 2018-07-30 13:47:08.000000000 +0200
+++ tests/xbps/libxbps/config/main.c 2018-08-07 08:37:37.900690953 +0200
@@ -39,6 +39,8 @@
struct xbps_handle xh;
const char *tcsdir;
char *buf, *buf2, pwd[PATH_MAX];
+ char confdir[PATH_MAX + 1 + sizeof("xbps.d")];
+ size_t len;
/* get test source dir */
tcsdir = atf_tc_get_config_var(tc, "srcdir");
@@ -48,7 +50,9 @@
xbps_strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, pwd, sizeof(xh.metadir));
- snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd);
+ len = snprintf(confdir, sizeof(confdir), "%s/xbps.d", pwd);
+ ATF_REQUIRE_EQ((len < sizeof(xh.confdir)), 1);
+ memcpy(xh.confdir, confdir, len + 1);
ATF_REQUIRE_EQ(xbps_mkpath(xh.confdir, 0755), 0);
@@ -88,6 +88,8 @@
struct xbps_handle xh;
const char *tcsdir;
char *buf, *buf2, pwd[PATH_MAX];
+ char confdir[PATH_MAX + 1 + sizeof("xbps.d")];
+ size_t len;
/* get test source dir */
tcsdir = atf_tc_get_config_var(tc, "srcdir");
@@ -97,7 +99,9 @@
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
- snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd);
+ len = snprintf(confdir, sizeof(confdir), "%s/xbps.d", pwd);
+ ATF_REQUIRE_EQ((len < sizeof(xh.confdir)), 1);
+ memcpy(xh.confdir, confdir, len + 1);
ATF_REQUIRE_EQ(xbps_mkpath(xh.confdir, 0755), 0);

View File

@ -0,0 +1,25 @@
--- lib/initend.c 2018-07-30 13:47:08.000000000 +0200
+++ lib/initend.c 2018-08-07 08:28:24.261662391 +0200
@@ -398,6 +398,7 @@
{
struct utsname un;
char cwd[PATH_MAX-1], sysconfdir[XBPS_MAXPATH+sizeof(XBPS_SYSDEFCONF_PATH)], *buf;
+ char relpath[PATH_MAX+1+XBPS_MAXPATH];
const char *repodir, *native_arch;
int rv;
@@ -412,9 +413,13 @@
xhp->rootdir[0] = '/';
xhp->rootdir[1] = '\0';
} else if (xhp->rootdir[0] != '/') {
+ size_t len;
buf = strdup(xhp->rootdir);
- snprintf(xhp->rootdir, sizeof(xhp->rootdir), "%s/%s", cwd, buf);
+ len = snprintf(relpath, sizeof(relpath), "%s/%s", cwd, buf);
free(buf);
+ if (len >= XBPS_MAXPATH)
+ return ENOTSUP;
+ memcpy(xhp->rootdir, relpath, len + 1);
}
xbps_dbg_printf(xhp, "%s\n", XBPS_RELVER);
/* set confdir */

View File

@ -0,0 +1,14 @@
--- bin/xbps-checkvers/main.c 2018-07-30 13:47:08.000000000 +0200
+++ bin/xbps-checkvers/main.c 2018-08-07 08:47:03.070720109 +0200
@@ -599,9 +599,9 @@
else
rcv->pkgd = xbps_rpool_get_pkg(&rcv->xhp, srcver);
- srcver = strncat(srcver, "-", 1);
+ srcver = strncat(srcver, "-", 2);
srcver = strncat(srcver, version.v.s, version.v.len);
- srcver = strncat(srcver, "_", 1);
+ srcver = strncat(srcver, "_", 2);
srcver = strncat(srcver, revision.v.s, revision.v.len);
xbps_dictionary_get_cstring_nocopy(rcv->pkgd, "pkgver", &repover);