libbb: make user/group name cache strings longer (~27 chars)
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 1 Mar 2011 15:27:13 +0000 (16:27 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 1 Mar 2011 15:27:13 +0000 (16:27 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
include/libbb.h
libbb/bb_pwd.c
libbb/procps.c

index 65c3194024248046aa7bf6e7c4d51bc00f0f51b1..c26012c5d8a4a05161ae86ada1142400479c9e49 100644 (file)
@@ -839,14 +839,14 @@ char* xuid2uname(uid_t uid) FAST_FUNC;
 char* xgid2group(gid_t gid) FAST_FUNC;
 char* uid2uname(uid_t uid) FAST_FUNC;
 char* gid2group(gid_t gid) FAST_FUNC;
-char* uid2uname_utoa(long uid) FAST_FUNC;
-char* gid2group_utoa(long gid) FAST_FUNC;
+char* uid2uname_utoa(uid_t uid) FAST_FUNC;
+char* gid2group_utoa(gid_t gid) FAST_FUNC;
 /* versions which cache results (useful for ps, ls etc) */
 const char* get_cached_username(uid_t uid) FAST_FUNC;
 const char* get_cached_groupname(gid_t gid) FAST_FUNC;
 void clear_username_cache(void) FAST_FUNC;
 /* internally usernames are saved in fixed-sized char[] buffers */
-enum { USERNAME_MAX_SIZE = 16 - sizeof(int) };
+enum { USERNAME_MAX_SIZE = 32 - sizeof(uid_t) };
 #if ENABLE_FEATURE_CHECK_NAMES
 void die_if_bad_username(const char* name) FAST_FUNC;
 #else
index 32406cb58e67f209dbfd97fdf72956fbe78a81c8..4829b723a0195163df5e937090d4c171ab9d8460 100644 (file)
@@ -72,13 +72,13 @@ char* FAST_FUNC gid2group(gid_t gid)
        return (gr) ? gr->gr_name : NULL;
 }
 
-char* FAST_FUNC uid2uname_utoa(long uid)
+char* FAST_FUNC uid2uname_utoa(uid_t uid)
 {
        char *name = uid2uname(uid);
        return (name) ? name : utoa(uid);
 }
 
-char* FAST_FUNC gid2group_utoa(long gid)
+char* FAST_FUNC gid2group_utoa(gid_t gid)
 {
        char *name = gid2group(gid);
        return (name) ? name : utoa(gid);
index fb4c320015b3ca010f743fa1fea2f62628d0d0de..5833a1f0d84fb0730ddc2c8fa2ef8d755b60115c 100644 (file)
 #include "libbb.h"
 
 
-typedef struct unsigned_to_name_map_t {
-       long id;
+typedef struct id_to_name_map_t {
+       uid_t id;
        char name[USERNAME_MAX_SIZE];
-} unsigned_to_name_map_t;
+} id_to_name_map_t;
 
 typedef struct cache_t {
-       unsigned_to_name_map_t *cache;
+       id_to_name_map_t *cache;
        int size;
 } cache_t;
 
@@ -39,7 +39,7 @@ void FAST_FUNC clear_username_cache(void)
 #if 0 /* more generic, but we don't need that yet */
 /* Returns -N-1 if not found. */
 /* cp->cache[N] is allocated and must be filled in this case */
-static int get_cached(cache_t *cp, unsigned id)
+static int get_cached(cache_t *cp, uid_t id)
 {
        int i;
        for (i = 0; i < cp->size; i++)
@@ -52,8 +52,8 @@ static int get_cached(cache_t *cp, unsigned id)
 }
 #endif
 
-static char* get_cached(cache_t *cp, long id,
-                       char* FAST_FUNC x2x_utoa(long id))
+static char* get_cached(cache_t *cp, uid_t id,
+                       char* FAST_FUNC x2x_utoa(uid_t id))
 {
        int i;
        for (i = 0; i < cp->size; i++)