public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage-utils:master commit in: /, tests/qdepends/
Date: Sat, 22 Mar 2014 05:31:00 +0000 (UTC)	[thread overview]
Message-ID: <1395465449.32e502323764acfb837dd35902c68abf136bfb17.vapier@gentoo> (raw)

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


                 reply	other threads:[~2014-03-22  5:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395465449.32e502323764acfb837dd35902c68abf136bfb17.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox