[CVS] RPM: rpm-5_4: rpm/ CHANGES rpm/rpmdb/ fprint.c

2011-05-27 Thread Pinto Elia
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Pinto Elia
  Root:   /v/rpm/cvs   Email:  devzero2...@rpm5.org
  Module: rpm  Date:   27-May-2011 15:50:13
  Branch: rpm-5_4  Handle: 2011052713501201

  Modified files:   (Branch: rpm-5_4)
rpm CHANGES
rpm/rpmdb   fprint.c

  Log:
In fpLookupSubdir, data returned by hash should be of type
struct rpmffi_s ** instead of struct rpmffi_s * to avoid
segfault. Patch by Qing He.

  Summary:
RevisionChanges Path
1.3501.2.133+3  -0  rpm/CHANGES
1.40.4.1+3  -3  rpm/rpmdb/fprint.c
  

  patch -p0 '@@ .'
  Index: rpm/CHANGES
  
  $ cvs diff -u -r1.3501.2.132 -r1.3501.2.133 CHANGES
  --- rpm/CHANGES   24 May 2011 10:48:50 -  1.3501.2.132
  +++ rpm/CHANGES   27 May 2011 13:50:12 -  1.3501.2.133
  @@ -1,4 +1,7 @@
   5.4.0 - 5.4.1:
  +- devzero2000: In fpLookupSubdir, data returned by hash should be of type
  +  struct rpmffi_s ** instead of struct rpmffi_s * to avoid
  +  segfault. Patch by Qing He.
   - devzero2000: added gcc-c++ in devtool.conf for fedora (required by 
beecrypt)
   - devzero2000: added fedora per platform macro from redhat-rpm-config
   - devzero2000: added suse to the per vendor change configure.ac enabler
  @@ .
  patch -p0 '@@ .'
  Index: rpm/rpmdb/fprint.c
  
  $ cvs diff -u -r1.40 -r1.40.4.1 fprint.c
  --- rpm/rpmdb/fprint.c6 Mar 2010 16:20:46 -   1.40
  +++ rpm/rpmdb/fprint.c27 May 2011 13:50:13 -  1.40.4.1
  @@ -333,7 +333,7 @@
   *te = '\0';
   
   while (te  se) {
  - struct rpmffi_s * recs;
  + struct rpmffi_s ** recs;
int numRecs;
int i;
   
  @@ -346,8 +346,8 @@
const char * link;
int fx;
   
  - fx = recs[i].fileno;
  - fi =  recs[i].p-fi;
  + fx = recs[i]-fileno;
  + fi =  recs[i]-p-fi;
flink = fi-flinks[fx];
if (!(flink  *flink != '\0'))
continue;
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm-5_3: rpm/rpmdb/ rpmdb.c

2011-05-27 Thread Per �yvind Karlsen
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Per Øyvind Karlsen
  Root:   /v/rpm/cvs   Email:  pkarl...@rpm5.org
  Module: rpm  Date:   27-May-2011 16:50:27
  Branch: rpm-5_3  Handle: 2011052714502700

  Modified files:   (Branch: rpm-5_3)
rpm/rpmdb   rpmdb.c

  Log:
come up with a better hack for querying nvra with disttag/distepoch
that should be rather generic

  Summary:
RevisionChanges Path
1.386.2.12  +80 -12 rpm/rpmdb/rpmdb.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmdb/rpmdb.c
  
  $ cvs diff -u -r1.386.2.11 -r1.386.2.12 rpmdb.c
  --- rpm/rpmdb/rpmdb.c 24 Mar 2011 16:51:17 -  1.386.2.11
  +++ rpm/rpmdb/rpmdb.c 27 May 2011 14:50:27 -  1.386.2.12
  @@ -2446,24 +2446,92 @@
/* XXX Special case #4: gather primary keys with patterns. */
rpmRC rc;
   
  + rc = dbiFindMatches(dbi, keyp, set);
   #if defined(RPM_VENDOR_MANDRIVA)
/*
  -  * ugly hack to workaround disttag/distepoch pattern matching issue to 
buy some
  +  * Hack to workaround disttag/distepoch pattern matching issue to buy 
some
 * time to come up with better pattern fix..
  +  * One size should fit all now.. ;)
  +  *
  +  * This patch will try match NVR first, then for all matches returned,
  +  * it will match disttag, distepoch  arch individually.
 */
  - const char *tmp = strstr(keyp, -mdv2011.0);
  - if(tmp) {
  - const char *origkeyp = keyp;
  - size_t klen = strlen(keyp);
  - keyp = alloca(klen);
  - memset((void*)keyp, klen, 0);
  - klen = tmp-origkeyp+1;
  - snprintf((char*)keyp, klen, %s, origkeyp);
  - if(strlen(tmp)  sizeof(-mdv2011.0)-1)
  - stpcpy((char*)keyp+(klen-1), tmp[sizeof(-mdv2011.0)-1]);
  +
  + /* We'll only try this if query fails */
  + if(!rc  ((const char*)keyp)[0] != '^'  tag == RPMTAG_NVRA 
  + (set == NULL || set-count  1)) {
  + size_t i;
  + char *tmp = (char*)keyp;
  +
  + /* If pattern has less than three '-', it can't contain disttag, so
  +  * no point in trying */
  + for (i = 0; (tmp = strchr(tmp, '-')); i++, tmp++);
  + if (i = 3) {
  + dbiIndex pdbi;
  + DBC *pdbc;
  + const char *origkeyp = keyp;
  + size_t klen = strlen(keyp)+1;
  + size_t size = 0;
  + int xx;
  +
  + keyp = alloca(klen);
  + stpcpy((char*)keyp, origkeyp);
  + tmp = strrchr(keyp, '-');
  + *tmp = '\0';
  + rc = dbiFindMatches(dbi, keyp, set);
  +
  + pdbi = dbiOpen(db, RPMDBI_PACKAGES, 0);
  + xx = dbiCopen(pdbi, dbiTxnid(pdbi), pdbc, 0);
  +
  + for(i = 0; i  set-count; i++) {
  + DBT k = DBT_INIT;
  + DBT v = DBT_INIT;
  + Header h;
  + uint32_t offset = _hton_ui(set-recs[i].hdrNum);
  + rpmTag checkTags[] =
  + { RPMTAG_DISTTAG, RPMTAG_DISTEPOCH, RPMTAG_ARCH };
  + int j;
  +
  + memset(k, 0, sizeof(k));
  + memset(v, 0, sizeof(v));
  + k.data = offset;
  + k.size = sizeof(offset);
  +
  + xx = dbiGet(dbi, pdbc, k, v, DB_SET);
  + h = headerLoad(v.data);
  + tmp = (char*)((size_t)keyp + strlen(keyp) + 1);
  +
  + for (j = 0; j  
(int)(sizeof(checkTags)/sizeof(checkTags[0])) 
  + *tmp != '\0'; j++) {
  + he-tag = checkTags[j];
  + if(headerGet(h, he, 0)) {
  + size_t len = strlen(he-p.str);
  +
  + if (he-tag == RPMTAG_ARCH  *tmp == '.')
  + tmp++;
  +
  + if(!strncmp(he-p.str, tmp, len))
  + tmp += len;
  + _free(he-p.ptr);
  + }
  + }
  + if(j  *tmp  == '\0') {
  + set-recs[size].hdrNum = set-recs[i].hdrNum;
  + set-recs[size].tagNum = set-recs[i].tagNum;
  + size++;
  + }
  +
  + h = headerFree(h);
  + }
  + if(set-count != size) {
  + set-count = size;
  + set-recs = realloc(set-recs, size * sizeof(*set-recs));
  + }
  +
  + xx = dbiCclose(pdbi, pdbc, 0);