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

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   02-Jan-2011 20:08:30
  Branch: rpm-5_4                          Handle: 2011010219082901

  Modified files:           (Branch: rpm-5_4)
    rpm                     CHANGES
    rpm/rpmio               ugid.c

  Log:
    - ugid: use the re-entrant user/group lookups.

  Summary:
    Revision    Changes     Path
    1.3501.2.40 +1  -0      rpm/CHANGES
    2.12.4.1    +26 -20     rpm/rpmio/ugid.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.3501.2.39 -r1.3501.2.40 CHANGES
  --- rpm/CHANGES       2 Jan 2011 17:22:03 -0000       1.3501.2.39
  +++ rpm/CHANGES       2 Jan 2011 19:08:29 -0000       1.3501.2.40
  @@ -1,4 +1,5 @@
   5.4.0 -> 5.4.1:
  +    - jbj: ugid: use the re-entrant user/group lookups.
       - jbj: valgrind: empty macros for *everything* to see the namespace.
       - jbj: mongo: stub-in mongo:// and mongodb:// URI's.
       - jbj: verify: overlap header-only signature/digest with file digests.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/ugid.c
  ============================================================================
  $ cvs diff -u -r2.12 -r2.12.4.1 ugid.c
  --- rpm/rpmio/ugid.c  19 Mar 2010 22:27:43 -0000      2.12
  +++ rpm/rpmio/ugid.c  2 Jan 2011 19:08:30 -0000       2.12.4.1
  @@ -19,7 +19,9 @@
       static size_t lastUnameLen = 0;
       static size_t lastUnameAlloced;
       static uid_t lastUid;
  -    struct passwd * pwent;
  +    struct passwd _pw, *pwent = NULL;
  +    char _b[BUFSIZ];
  +    size_t _nb = sizeof(_b);
       size_t thisUnameLen;
   
   #ifdef       SUSE_REFERENCE
  @@ -31,7 +33,7 @@
   mail
   lp
   #endif
  -    if (!thisUname) {
  +    if (thisUname == NULL) {
        lastUnameLen = 0;
        return -1;
   #if !defined(RPM_VENDOR_OPENPKG) /* no-hard-coded-ugid */
  @@ -47,19 +49,17 @@
       {
        if (lastUnameAlloced < thisUnameLen + 1) {
            lastUnameAlloced = thisUnameLen + 10;
  -         lastUname = (char *) xrealloc(lastUname, lastUnameAlloced);
  +         lastUname = (char *) DRD_xrealloc(lastUname, lastUnameAlloced);
        }
        strcpy(lastUname, thisUname);
   
  -     pwent = getpwnam(thisUname);
  -     if (pwent == NULL) {
  +     if (getpwnam_r(thisUname, &_pw, _b, _nb, &pwent) || pwent == NULL) {
            /*...@-internalglobs@*/ /* FIX: shrug */
            endpwent();
            /*...@=internalglobs@*/
  -         pwent = getpwnam(thisUname);
  -         if (pwent == NULL) return -1;
  +         if (getpwnam_r(thisUname, &_pw, _b, _nb, &pwent) || pwent == NULL)
  +             return -1;
        }
  -
        lastUid = pwent->pw_uid;
       }
   
  @@ -74,8 +74,10 @@
       static size_t lastGnameLen = 0;
       static size_t lastGnameAlloced;
       static gid_t lastGid;
  +    struct group _gr, *grent = NULL;
  +    char _b[BUFSIZ];
  +    size_t _nb = sizeof(_b);
       size_t thisGnameLen;
  -    struct group * grent;
   
   #ifdef       SUSE_REFERENCE
   news
  @@ -99,17 +101,15 @@
       {
        if (lastGnameAlloced < thisGnameLen + 1) {
            lastGnameAlloced = thisGnameLen + 10;
  -         lastGname = (char *) xrealloc(lastGname, lastGnameAlloced);
  +         lastGname = (char *) DRD_xrealloc(lastGname, lastGnameAlloced);
        }
        strcpy(lastGname, thisGname);
   
  -     grent = getgrnam(thisGname);
  -     if (grent == NULL) {
  +     if (getgrnam_r(thisGname, &_gr, _b, _nb, &grent) || grent == NULL) {
            /*...@-internalglobs@*/ /* FIX: shrug */
            endgrent();
            /*...@=internalglobs@*/
  -         grent = getgrnam(thisGname);
  -         if (grent == NULL) {
  +         if (getgrnam_r(thisGname, &_gr, _b, _nb, &grent) || grent == NULL) {
   #if !defined(RPM_VENDOR_OPENPKG) /* no-hard-coded-ugid */
                /* XXX The filesystem package needs group/lock w/o getgrnam. */
                if (strcmp(thisGname, "lock") == 0) {
  @@ -148,16 +148,19 @@
       } else if (uid == lastUid) {
        return lastUname;
       } else {
  -     struct passwd * pwent = getpwuid(uid);
  +     struct passwd _pw, *pwent = NULL;
  +     char _b[BUFSIZ];
  +     size_t _nb = sizeof(_b);
        size_t len;
   
  -     if (pwent == NULL) return NULL;
  +     if (getpwuid_r(uid, &_pw, _b, _nb, &pwent) || pwent == NULL)
  +         return NULL;
   
        lastUid = uid;
        len = strlen(pwent->pw_name);
        if (lastUnameLen < len + 1) {
            lastUnameLen = len + 20;
  -         lastUname = (char *) xrealloc(lastUname, lastUnameLen);
  +         lastUname = (char *) DRD_xrealloc(lastUname, lastUnameLen);
        }
        strcpy(lastUname, pwent->pw_name);
   
  @@ -181,16 +184,19 @@
       } else if (gid == lastGid) {
        return lastGname;
       } else {
  -     struct group * grent = getgrgid(gid);
  +     struct group _gr, *grent = NULL;
  +     char _b[BUFSIZ];
  +     size_t _nb = sizeof(_b);
        size_t len;
   
  -     if (grent == NULL) return NULL;
  +     if (getgrgid_r(gid, &_gr, _b, _nb, &grent) || grent == NULL)
  +         return NULL;
   
        lastGid = gid;
        len = strlen(grent->gr_name);
        if (lastGnameLen < len + 1) {
            lastGnameLen = len + 20;
  -         lastGname = (char *) xrealloc(lastGname, lastGnameLen);
  +         lastGname = (char *) DRD_xrealloc(lastGname, lastGnameLen);
        }
        strcpy(lastGname, grent->gr_name);
   
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to