public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage-utils:master commit in: /, tests/qdepends/
@ 2014-03-22  5:31 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2014-03-22  5:31 UTC (permalink / raw
  To: gentoo-commits

commit:     32e502323764acfb837dd35902c68abf136bfb17
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 22 05:17:29 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Mar 22 05:17:29 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=32e50232

qdepends: fix (another) assert after eat_file rework

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

---
 qdepends.c                 | 9 ++++++---
 tests/qdepends/dotest      | 7 ++++++-
 tests/qdepends/list08.good | 1 +
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-03-22  5:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-22  5:31 [gentoo-commits] proj/portage-utils:master commit in: /, tests/qdepends/ Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox