RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [email protected]
  Module: rpm                              Date:   18-May-2009 20:09:28
  Branch: HEAD                             Handle: 2009051818092800

  Modified files:
    rpm/rpmdb               header.c

  Log:
    - force PROT_READ onto rpmdb header blob's, swab on headerGet() access
    instead.

  Summary:
    Revision    Changes     Path
    1.183       +11 -7      rpm/rpmdb/header.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.c
  ============================================================================
  $ cvs diff -u -r1.182 -r1.183 header.c
  --- rpm/rpmdb/header.c        18 May 2009 02:12:40 -0000      1.182
  +++ rpm/rpmdb/header.c        18 May 2009 18:09:28 -0000      1.183
  @@ -34,7 +34,7 @@
   
   /* Swab tag data only when accessed through headerGet()? */
   /*...@unchecked@*/
  -int _hdr_lazytagswab = 0;
  +int _hdr_lazytagswab = 1;
   
   /** \ingroup header
    */
  @@ -379,6 +379,7 @@
       switch (he->t) {
       case RPM_UINT64_TYPE:
       {        rpmuint32_t * tt = (rpmuint32_t *)t;
  +assert(nb == (he->c * sizeof(*tt)));
        for (i = 0; i < he->c; i++) {
            rpmuint32_t j = 2 * i;
            rpmuint32_t b = (rpmuint32_t) htonl(he->p.ui32p[j]);
  @@ -388,11 +389,13 @@
       }   break;
       case RPM_UINT32_TYPE:
       {        rpmuint32_t * tt = (rpmuint32_t *)t;
  +assert(nb == (he->c * sizeof(*tt)));
        for (i = 0; i < he->c; i++)
            tt[i] = (rpmuint32_t) htonl(he->p.ui32p[i]);
       }   break;
       case RPM_UINT16_TYPE:
       {        rpmuint16_t * tt = (rpmuint16_t *)t;
  +assert(nb == (he->c * sizeof(*tt)));
        for (i = 0; i < he->c; i++)
            tt[i] = (rpmuint16_t) htons(he->p.ui16p[i]);
       }   break;
  @@ -1400,13 +1403,14 @@
                NULL, pvlen, prot, flags, fdno, (unsigned)off,
                errno, strerror(errno));
        memcpy(nuh, uh, pvlen);
  -     if ((nh = headerLoad(nuh)) != NULL) {
  +     if (mprotect(nuh, pvlen, PROT_READ) != 0)
  +         fprintf(stderr, "==> mprotect(%p[%u],0x%x) error(%d): %s\n",
  +                     nuh, pvlen, PROT_READ,
  +                     errno, strerror(errno));
  +     nh = headerLoad(nuh);
  +     if (nh != NULL) {
   assert(nh->bloblen == pvlen);
            nh->flags |= HEADERFLAG_MAPPED;
  -         if (mprotect(nh->blob, nh->bloblen, PROT_READ) != 0)
  -             fprintf(stderr, "==> mprotect(%p[%u],0x%x) error(%d): %s\n",
  -                     nh->blob, nh->bloblen, PROT_READ,
  -                     errno, strerror(errno));
            nh->flags |= HEADERFLAG_RDONLY;
        } else {
            if (munmap(nuh, pvlen) != 0)
  @@ -1726,7 +1730,7 @@
       }
   
       /* XXX 1 on success */
  -    return ((rc == 1) ? 1 : 0);
  +    return (rc == 1 ? 1 : 0);
   }
   
   /**
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to