From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id C4DAB1391DB for ; Sat, 22 Mar 2014 05:31:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6F665E0B24; Sat, 22 Mar 2014 05:31:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D3F7BE0B24 for ; Sat, 22 Mar 2014 05:31:03 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D7D6333FD16 for ; Sat, 22 Mar 2014 05:31:02 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id AC9D118875 for ; Sat, 22 Mar 2014 05:31:00 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1395465449.32e502323764acfb837dd35902c68abf136bfb17.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: /, tests/qdepends/ X-VCS-Repository: proj/portage-utils X-VCS-Files: qdepends.c tests/qdepends/dotest tests/qdepends/list08.good X-VCS-Directories: / tests/qdepends/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 32e502323764acfb837dd35902c68abf136bfb17 X-VCS-Branch: master Date: Sat, 22 Mar 2014 05:31:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: f61c77f3-64c7-4fa4-82c8-695368a137b6 X-Archives-Hash: 381dad9c6865fe9f8c75a266b25ff601 commit: 32e502323764acfb837dd35902c68abf136bfb17 Author: Mike Frysinger gentoo org> AuthorDate: Sat Mar 22 05:17:29 2014 +0000 Commit: Mike Frysinger gentoo 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-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