Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /, tests/qdepends/
Date: Sat, 22 Mar 2014 05:31:08
Message-Id: 1395465449.32e502323764acfb837dd35902c68abf136bfb17.vapier@gentoo
1 commit: 32e502323764acfb837dd35902c68abf136bfb17
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 22 05:17:29 2014 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 22 05:17:29 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=32e50232
7
8 qdepends: fix (another) assert after eat_file rework
9
10 The assert no longer makes sense since the buffer is dynamically
11 allocated. Rework the logic to handle any sized buffer.
12
13 URL: https://bugs.gentoo.org/504636
14
15 ---
16 qdepends.c | 9 ++++++---
17 tests/qdepends/dotest | 7 ++++++-
18 tests/qdepends/list08.good | 1 +
19 3 files changed, 13 insertions(+), 4 deletions(-)
20
21 diff --git a/qdepends.c b/qdepends.c
22 index 96f757b..648d8e2 100644
23 --- a/qdepends.c
24 +++ b/qdepends.c
25 @@ -440,8 +440,11 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
26 for (ptr = use; *ptr; ++ptr)
27 if (*ptr == '\n' || *ptr == '\t')
28 *ptr = ' ';
29 - len = strlen(use);
30 - assert(len+1 < sizeof(use));
31 + len = ptr - use;
32 + if (len + 1 >= use_len) {
33 + use_len += BUFSIZE;
34 + use = xrealloc(use, use_len);
35 + }
36 use[len] = ' ';
37 use[len+1] = '\0';
38 memmove(use+1, use, len);
39 @@ -490,7 +493,7 @@ _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
40 if (*ptr == '\n' || *ptr == '\t')
41 *ptr = ' ';
42 len = ptr - use;
43 - if (len == use_len) {
44 + if (len + 1 >= use_len) {
45 use_len += BUFSIZE;
46 use = xrealloc(use, use_len);
47 }
48
49 diff --git a/tests/qdepends/dotest b/tests/qdepends/dotest
50 index cb1f457..8421577 100755
51 --- a/tests/qdepends/dotest
52 +++ b/tests/qdepends/dotest
53 @@ -26,7 +26,7 @@ test() {
54 cp list "${good}"
55 fi
56 diff -u list "${good}"
57 - tend $? "${cmd[*]}"
58 + tend $? "${num} ${cmd[*]}"
59 }
60
61 testf() { test "$1" "${3:-0}" -f "$2"; }
62 @@ -49,6 +49,11 @@ testQ() { test "$1" "${3:-0}" -Q "$2"; }
63 # reverse checks #504636
64 testQ 07 xinit
65
66 +testq() { test "$1" "${3:-0}" -q "$2"; }
67 +
68 +# forward checks #504636
69 +testq 08 xdm
70 +
71 cleantmpdir
72
73 end
74
75 diff --git a/tests/qdepends/list08.good b/tests/qdepends/list08.good
76 new file mode 100644
77 index 0000000..bad1799
78 --- /dev/null
79 +++ b/tests/qdepends/list08.good
80 @@ -0,0 +1 @@
81 +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