0016-pwcache-Don-t-use-fixed-buffer-sizes.patch (2648B)
1 From ab480e176692b91f2fb6fb9ea2e1725d980d805d Mon Sep 17 00:00:00 2001 2 From: Michael Forney <mforney@mforney.org> 3 Date: Fri, 14 Apr 2017 11:25:01 -0700 4 Subject: [PATCH] pwcache: Don't use fixed buffer sizes 5 6 --- 7 lib/libc/gen/pwcache.c | 20 ++++++++------------ 8 1 file changed, 8 insertions(+), 12 deletions(-) 9 10 diff --git a/lib/libc/gen/pwcache.c b/lib/libc/gen/pwcache.c 11 index d54daa08cc7..2f30f4b966b 100644 12 --- a/lib/libc/gen/pwcache.c 13 +++ b/lib/libc/gen/pwcache.c 14 @@ -202,8 +202,7 @@ grptb_start(void) 15 const char * 16 user_from_uid(uid_t uid, int noname) 17 { 18 - struct passwd pwstore, *pw = NULL; 19 - char pwbuf[_PW_BUF_LEN]; 20 + struct passwd *pw; 21 UIDC **pptr, *ptr = NULL; 22 23 if ((uidtb != NULL) || (uidtb_start() == 0)) { 24 @@ -226,7 +225,7 @@ user_from_uid(uid_t uid, int noname) 25 *pptr = ptr = malloc(sizeof(UIDC)); 26 } 27 28 - getpwuid_r(uid, &pwstore, pwbuf, sizeof(pwbuf), &pw); 29 + pw = getpwuid(uid); 30 if (pw == NULL) { 31 /* 32 * no match for this uid in the local password file 33 @@ -263,8 +262,7 @@ user_from_uid(uid_t uid, int noname) 34 const char * 35 group_from_gid(gid_t gid, int noname) 36 { 37 - struct group grstore, *gr = NULL; 38 - char grbuf[_GR_BUF_LEN]; 39 + struct group *gr; 40 GIDC **pptr, *ptr = NULL; 41 42 if ((gidtb != NULL) || (gidtb_start() == 0)) { 43 @@ -287,7 +285,7 @@ group_from_gid(gid_t gid, int noname) 44 *pptr = ptr = malloc(sizeof(GIDC)); 45 } 46 47 - getgrgid_r(gid, &grstore, grbuf, sizeof(grbuf), &gr); 48 + gr = getgrgid(gid); 49 if (gr == NULL) { 50 /* 51 * no match for this gid in the local group file, put in 52 @@ -322,8 +320,7 @@ group_from_gid(gid_t gid, int noname) 53 int 54 uid_from_user(const char *name, uid_t *uid) 55 { 56 - struct passwd pwstore, *pw = NULL; 57 - char pwbuf[_PW_BUF_LEN]; 58 + struct passwd *pw; 59 UIDC **pptr, *ptr = NULL; 60 size_t namelen; 61 62 @@ -357,7 +354,7 @@ uid_from_user(const char *name, uid_t *uid) 63 * no match, look it up, if no match store it as an invalid entry, 64 * or store the matching uid 65 */ 66 - getpwnam_r(name, &pwstore, pwbuf, sizeof(pwbuf), &pw); 67 + pw = getpwnam(name); 68 if (ptr == NULL) { 69 if (pw == NULL) 70 return -1; 71 @@ -383,8 +380,7 @@ uid_from_user(const char *name, uid_t *uid) 72 int 73 gid_from_group(const char *name, gid_t *gid) 74 { 75 - struct group grstore, *gr = NULL; 76 - char grbuf[_GR_BUF_LEN]; 77 + struct group *gr; 78 GIDC **pptr, *ptr = NULL; 79 size_t namelen; 80 81 @@ -418,7 +414,7 @@ gid_from_group(const char *name, gid_t *gid) 82 * no match, look it up, if no match store it as an invalid entry, 83 * or store the matching gid 84 */ 85 - getgrnam_r(name, &grstore, grbuf, sizeof(grbuf), &gr); 86 + gr = getgrnam(name); 87 if (ptr == NULL) { 88 if (gr == NULL) 89 return -1; 90 -- 91 2.19.0 92