[be36855] | 1 | Submitted By: Jim Gifford <jim at linuxfromscratch dot org>
|
---|
| 2 | Date: 2006-11-20
|
---|
| 3 | Initial Package Version: 6.5
|
---|
| 4 | Upstream Status: Applied
|
---|
| 5 | Origin: http://lists.gnu.org/archive/html/bug-coreutils/2006-11/msg00156.html
|
---|
| 6 | Description: Fixes a segfault with in ls
|
---|
| 7 |
|
---|
| 8 | diff -Naur coreutils-6.5.orig/lib/idcache.c coreutils-6.5/lib/idcache.c
|
---|
| 9 | --- coreutils-6.5.orig/lib/idcache.c 2006-11-07 06:42:11.000000000 -0800
|
---|
| 10 | +++ coreutils-6.5/lib/idcache.c 2006-11-20 23:16:09.000000000 -0800
|
---|
| 11 | @@ -19,7 +19,6 @@
|
---|
| 12 |
|
---|
| 13 | #include <config.h>
|
---|
| 14 |
|
---|
| 15 | -#include <stddef.h>
|
---|
| 16 | #include <stdio.h>
|
---|
| 17 | #include <string.h>
|
---|
| 18 | #include <sys/types.h>
|
---|
| 19 | @@ -41,8 +40,8 @@
|
---|
| 20 | uid_t u;
|
---|
| 21 | gid_t g;
|
---|
| 22 | } id;
|
---|
| 23 | + char *name;
|
---|
| 24 | struct userid *next;
|
---|
| 25 | - char name[FLEXIBLE_ARRAY_MEMBER];
|
---|
| 26 | };
|
---|
| 27 |
|
---|
| 28 | static struct userid *user_alist;
|
---|
| 29 | @@ -57,17 +56,15 @@
|
---|
| 30 | {
|
---|
| 31 | register struct userid *tail;
|
---|
| 32 | struct passwd *pwent;
|
---|
| 33 | - char const *name;
|
---|
| 34 |
|
---|
| 35 | for (tail = user_alist; tail; tail = tail->next)
|
---|
| 36 | if (tail->id.u == uid)
|
---|
| 37 | return tail->name;
|
---|
| 38 |
|
---|
| 39 | pwent = getpwuid (uid);
|
---|
| 40 | - name = pwent ? pwent->pw_name : "";
|
---|
| 41 | - tail = xmalloc (offsetof (struct userid, name) + strlen (name) + 1);
|
---|
| 42 | + tail = xmalloc (sizeof *tail);
|
---|
| 43 | tail->id.u = uid;
|
---|
| 44 | - strcpy (tail->name, name);
|
---|
| 45 | + tail->name = pwent ? xstrdup (pwent->pw_name) : NULL;
|
---|
| 46 |
|
---|
| 47 | /* Add to the head of the list, so most recently used is first. */
|
---|
| 48 | tail->next = user_alist;
|
---|
| 49 | @@ -107,8 +104,8 @@
|
---|
| 50 | }
|
---|
| 51 | #endif
|
---|
| 52 |
|
---|
| 53 | - tail = xmalloc (offsetof (struct userid, name) + strlen (user) + 1);
|
---|
| 54 | - strcpy (tail->name, user);
|
---|
| 55 | + tail = xmalloc (sizeof *tail);
|
---|
| 56 | + tail->name = xstrdup (user);
|
---|
| 57 |
|
---|
| 58 | /* Add to the head of the list, so most recently used is first. */
|
---|
| 59 | if (pwent)
|
---|
| 60 | @@ -135,17 +132,15 @@
|
---|
| 61 | {
|
---|
| 62 | register struct userid *tail;
|
---|
| 63 | struct group *grent;
|
---|
| 64 | - char const *name;
|
---|
| 65 |
|
---|
| 66 | for (tail = group_alist; tail; tail = tail->next)
|
---|
| 67 | if (tail->id.g == gid)
|
---|
| 68 | return tail->name;
|
---|
| 69 |
|
---|
| 70 | grent = getgrgid (gid);
|
---|
| 71 | - name = grent ? grent->gr_name : NULL;
|
---|
| 72 | - tail = xmalloc (offsetof (struct userid, name) + strlen (name) + 1);
|
---|
| 73 | + tail = xmalloc (sizeof *tail);
|
---|
| 74 | tail->id.g = gid;
|
---|
| 75 | - strcpy (tail->name, name);
|
---|
| 76 | + tail->name = grent ? xstrdup (grent->gr_name) : NULL;
|
---|
| 77 |
|
---|
| 78 | /* Add to the head of the list, so most recently used is first. */
|
---|
| 79 | tail->next = group_alist;
|
---|
| 80 | @@ -185,8 +180,8 @@
|
---|
| 81 | }
|
---|
| 82 | #endif
|
---|
| 83 |
|
---|
| 84 | - tail = xmalloc (offsetof (struct userid, name) + strlen (group) + 1);
|
---|
| 85 | - strcpy (tail->name, group);
|
---|
| 86 | + tail = xmalloc (sizeof *tail);
|
---|
| 87 | + tail->name = xstrdup (group);
|
---|
| 88 |
|
---|
| 89 | /* Add to the head of the list, so most recently used is first. */
|
---|
| 90 | if (grent)
|
---|