RPM Community Forums

Mailing List Message of <rpm-devel>

Re: rpm-5.1.2 query segfault on certain uninstalled names

From: Jeff Johnson <n3npq@mac.com>
Date: Wed 11 Jun 2008 - 05:29:29 CEST
Message-id: <2BCD4819-3348-4A2A-99C9-AFBB6A58B877@mac.com>

On Jun 7, 2008, at 1:15 PM, Dan Nicholson wrote:

> On Sat, Jun 7, 2008 at 12:00 AM, Ralf S. Engelschall
> <rse+rpm-devel@rpm5.org> wrote:
>>
>> I cannot reproduce this under OpenPKG's RPM 5.1.2 and on a FreeBSD
>> platform, too:
>>
>> | $ openpkg rpm --version
>> | rpm (OpenPKG RPM) 5.1.2
>> | $ openpkg rpm -q perl
>> | perl-5.10.0-20080413
>> | $ openpkg rpm -q perl-util
>> | perl-util-5.10.0-20080528
>
> The issue occurs when querying for an _uninstalled_ package with the
> same name prefix. So, in your case, probably searching for "perl-foo"
> would be a good test.
>

Ah, this patch will likely fix your segfault:

Index: mire.c
===================================================================
RCS file: /v/rpm/cvs/rpm/rpmio/mire.c,v
retrieving revision 1.41
diff -u -b -B -w -p -r1.41 mire.c
--- mire.c      12 Mar 2008 19:41:13 -0000      1.41
+++ mire.c      11 Jun 2008 03:18:52 -0000
@@ -350,7 +350,6 @@ int mireRegcomp(miRE mire, const char *
      mire->pattern = xstrdup(pattern);

      switch (mire->mode) {
-    case RPMMIRE_DEFAULT:
      case RPMMIRE_STRCMP:
         break;
      case RPMMIRE_PCRE:
@@ -372,6 +371,7 @@ int mireRegcomp(miRE mire, const char *
         rc = -99;
  #endif
         break;
+    case RPMMIRE_DEFAULT:
      case RPMMIRE_REGEX:
         mire->preg = xcalloc(1, sizeof(*mire->preg));
         if (mire->cflags == 0)


The underlying issue is what type of match should be attached
to RPMMIRE_DEFAULT. I can tell from the constructed "^foo$"
pattern that a RE is being attempted. However, at some point
I changed my mind and decided that an RE was overkill when
only a strcmp(3) is needed. However the odd case of querying
non-existent uninstalled packages never got found until now.

The other, better, way to fix is what I will likely check-in tomorrow,
mapping RPMMIRE_DEFAULT onto a strcmp as I intended,
and changing the code in rpmdb/rpmdb.c to not bother building
the "^foo$" RE.

Apologies for not finding the issue sooner.

73 de Jeff
Received on Wed Jun 11 05:30:24 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.