aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2014-03-22 01:17:29 -0400
committerMike Frysinger <vapier@gentoo.org>2014-03-22 01:17:29 -0400
commit32e502323764acfb837dd35902c68abf136bfb17 (patch)
tree72cf40de2f6d51f958b09f75892b9a916e768cd6
parentwhich: punt! (diff)
downloadportage-utils-32e502323764acfb837dd35902c68abf136bfb17.tar.gz
portage-utils-32e502323764acfb837dd35902c68abf136bfb17.tar.bz2
portage-utils-32e502323764acfb837dd35902c68abf136bfb17.zip
qdepends: fix (another) assert after eat_file reworkv0.53
The assert no longer makes sense since the buffer is dynamically allocated. Rework the logic to handle any sized buffer. URL: https://bugs.gentoo.org/504636
-rw-r--r--qdepends.c9
-rwxr-xr-xtests/qdepends/dotest7
-rw-r--r--tests/qdepends/list08.good1
3 files changed, 13 insertions, 4 deletions
diff --git a/qdepends.c b/qdepends.c
index 96f757b..648d8e2 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -440,8 +440,11 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
for (ptr = use; *ptr; ++ptr)
if (*ptr == '\n' || *ptr == '\t')
*ptr = ' ';
- len = strlen(use);
- assert(len+1 < sizeof(use));
+ len = ptr - use;
+ if (len + 1 >= use_len) {
+ use_len += BUFSIZE;
+ use = xrealloc(use, use_len);
+ }
use[len] = ' ';
use[len+1] = '\0';
memmove(use+1, use, len);
@@ -490,7 +493,7 @@ _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
if (*ptr == '\n' || *ptr == '\t')
*ptr = ' ';
len = ptr - use;
- if (len == use_len) {
+ if (len + 1 >= use_len) {
use_len += BUFSIZE;
use = xrealloc(use, use_len);
}
diff --git a/tests/qdepends/dotest b/tests/qdepends/dotest
index cb1f457..8421577 100755
--- a/tests/qdepends/dotest
+++ b/tests/qdepends/dotest
@@ -26,7 +26,7 @@ test() {
cp list "${good}"
fi
diff -u list "${good}"
- tend $? "${cmd[*]}"
+ tend $? "${num} ${cmd[*]}"
}
testf() { test "$1" "${3:-0}" -f "$2"; }
@@ -49,6 +49,11 @@ testQ() { test "$1" "${3:-0}" -Q "$2"; }
# reverse checks #504636
testQ 07 xinit
+testq() { test "$1" "${3:-0}" -q "$2"; }
+
+# forward checks #504636
+testq 08 xdm
+
cleantmpdir
end
diff --git a/tests/qdepends/list08.good b/tests/qdepends/list08.good
new file mode 100644
index 0000000..bad1799
--- /dev/null
+++ b/tests/qdepends/list08.good
@@ -0,0 +1 @@
+x11-apps/xdm-1.1.11-r3: x11-apps/xrdb x11-libs/libXdmcp x11-libs/libXaw >=x11-apps/xinit-1.0.2-r3 x11-libs/libXinerama x11-libs/libXmu x11-libs/libX11 x11-libs/libXt x11-apps/sessreg x11-apps/xconsole !<sys-apps/systemd-187 x11-proto/xineramaproto x11-proto/xproto >=sys-devel/automake-1.12:1.12 >=sys-devel/automake-1.13:1.13 >=sys-devel/autoconf-2.68 sys-devel/libtool >=sys-devel/libtool-2.2.6a sys-devel/m4 >=x11-misc/util-macros-1.17 >=media-fonts/font-util-1.2.0 virtual/pkgconfig virtual/pkgconfig