source: patches/coreutils-6.5-id_cache-1.patch@ 7ee340e4

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 7ee340e4 was be36855, checked in by Jim Gifford <clfs@…>, 18 years ago

Update Coreutils Patch

  • Property mode set to 100644
File size: 2.5 KB
  • lib/idcache.c

    Submitted By: Jim Gifford <jim at linuxfromscratch dot org>
    Date: 2006-11-20
    Initial Package Version: 6.5
    Upstream Status: Applied
    Origin: http://lists.gnu.org/archive/html/bug-coreutils/2006-11/msg00156.html
    Description: Fixes a segfault with in ls
    
    diff -Naur coreutils-6.5.orig/lib/idcache.c coreutils-6.5/lib/idcache.c
    old new  
    1919
    2020#include <config.h>
    2121
    22 #include <stddef.h>
    2322#include <stdio.h>
    2423#include <string.h>
    2524#include <sys/types.h>
     
    4140      uid_t u;
    4241      gid_t g;
    4342    } id;
     43  char *name;
    4444  struct userid *next;
    45   char name[FLEXIBLE_ARRAY_MEMBER];
    4645};
    4746
    4847static struct userid *user_alist;
     
    5756{
    5857  register struct userid *tail;
    5958  struct passwd *pwent;
    60   char const *name;
    6159
    6260  for (tail = user_alist; tail; tail = tail->next)
    6361    if (tail->id.u == uid)
    6462      return tail->name;
    6563
    6664  pwent = getpwuid (uid);
    67   name = pwent ? pwent->pw_name : "";
    68   tail = xmalloc (offsetof (struct userid, name) + strlen (name) + 1);
     65  tail = xmalloc (sizeof *tail);
    6966  tail->id.u = uid;
    70   strcpy (tail->name, name);
     67  tail->name = pwent ? xstrdup (pwent->pw_name) : NULL;
    7168
    7269  /* Add to the head of the list, so most recently used is first.  */
    7370  tail->next = user_alist;
     
    107104    }
    108105#endif
    109106
    110   tail = xmalloc (offsetof (struct userid, name) + strlen (user) + 1);
    111   strcpy (tail->name, user);
     107  tail = xmalloc (sizeof *tail);
     108  tail->name = xstrdup (user);
    112109
    113110  /* Add to the head of the list, so most recently used is first.  */
    114111  if (pwent)
     
    135132{
    136133  register struct userid *tail;
    137134  struct group *grent;
    138   char const *name;
    139135
    140136  for (tail = group_alist; tail; tail = tail->next)
    141137    if (tail->id.g == gid)
    142138      return tail->name;
    143139
    144140  grent = getgrgid (gid);
    145   name = grent ? grent->gr_name : NULL;
    146   tail = xmalloc (offsetof (struct userid, name) + strlen (name) + 1);
     141  tail = xmalloc (sizeof *tail);
    147142  tail->id.g = gid;
    148   strcpy (tail->name, name);
     143  tail->name = grent ? xstrdup (grent->gr_name) : NULL;
    149144
    150145  /* Add to the head of the list, so most recently used is first.  */
    151146  tail->next = group_alist;
     
    185180    }
    186181#endif
    187182
    188   tail = xmalloc (offsetof (struct userid, name) + strlen (group) + 1);
    189   strcpy (tail->name, group);
     183  tail = xmalloc (sizeof *tail);
     184  tail->name = xstrdup (group);
    190185
    191186  /* Add to the head of the list, so most recently used is first.  */
    192187  if (grent)
Note: See TracBrowser for help on using the repository browser.