diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-03 19:12:49 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-03 19:12:49 +0100 |
commit | 20c0a16334e96493077eaaad6f4c5690af0aa6e8 (patch) | |
tree | 6aa89a4addec8b0398689300baf7dbb8592ddd73 | |
parent | 5e62a3d016633d4d97906f0f73298dc8e8b6a42b (diff) | |
download | busybox-w32-20c0a16334e96493077eaaad6f4c5690af0aa6e8.tar.gz busybox-w32-20c0a16334e96493077eaaad6f4c5690af0aa6e8.tar.bz2 busybox-w32-20c0a16334e96493077eaaad6f4c5690af0aa6e8.zip |
libpwdgrp: make db->def[] one byte shorter
In the future I will need another uint8_t, want to fit it
w/o using another word on 32 bits.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libpwdgrp/pwd_grp.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index f3fcec859..1b2418a8d 100644 --- a/libpwdgrp/pwd_grp.c +++ b/libpwdgrp/pwd_grp.c | |||
@@ -34,13 +34,13 @@ | |||
34 | 34 | ||
35 | struct const_passdb { | 35 | struct const_passdb { |
36 | const char *filename; | 36 | const char *filename; |
37 | const char def[10]; | 37 | const char def[9]; |
38 | const uint8_t off[9]; | 38 | const uint8_t off[9]; |
39 | uint8_t numfields; | 39 | uint8_t numfields; |
40 | }; | 40 | }; |
41 | struct passdb { | 41 | struct passdb { |
42 | const char *filename; | 42 | const char *filename; |
43 | const char def[10]; | 43 | const char def[9]; |
44 | const uint8_t off[9]; | 44 | const uint8_t off[9]; |
45 | uint8_t numfields; | 45 | uint8_t numfields; |
46 | FILE *fp; | 46 | FILE *fp; |
@@ -51,6 +51,11 @@ struct passdb { | |||
51 | IF_USE_BB_SHADOW(sizeof(struct spwd)) | 51 | IF_USE_BB_SHADOW(sizeof(struct spwd)) |
52 | ]; | 52 | ]; |
53 | }; | 53 | }; |
54 | /* Note: for shadow db, def[9] will not contain terminating NUL, | ||
55 | * but convert_to_struct() logic detects def[] end by "less than SP?", | ||
56 | * not by "is it NUL?" condition; and off[0] happens to be zero | ||
57 | * for every db anyway, so there _is_ in fact a terminating NUL there. | ||
58 | */ | ||
54 | 59 | ||
55 | /* S = string not empty, s = string maybe empty, | 60 | /* S = string not empty, s = string maybe empty, |
56 | * I = uid,gid, l = long maybe empty, m = members, | 61 | * I = uid,gid, l = long maybe empty, m = members, |
@@ -122,7 +127,7 @@ static void free_static(void) | |||
122 | free(S.db[0].malloced); | 127 | free(S.db[0].malloced); |
123 | free(S.db[1].malloced); | 128 | free(S.db[1].malloced); |
124 | # if ENABLE_USE_BB_SHADOW | 129 | # if ENABLE_USE_BB_SHADOW |
125 | S.db[2].malloced); | 130 | free(S.db[2].malloced); |
126 | # endif | 131 | # endif |
127 | free(ptr_to_statics); | 132 | free(ptr_to_statics); |
128 | } | 133 | } |
@@ -286,8 +291,8 @@ static void *convert_to_struct(struct passdb *db, | |||
286 | * at the end of malloced buffer! | 291 | * at the end of malloced buffer! |
287 | */ | 292 | */ |
288 | members = (char **) | 293 | members = (char **) |
289 | ( ((intptr_t)S.tokenize_end + sizeof(char**)) | 294 | ( ((intptr_t)S.tokenize_end + sizeof(members[0])) |
290 | & -(intptr_t)sizeof(char**) | 295 | & -(intptr_t)sizeof(members[0]) |
291 | ); | 296 | ); |
292 | 297 | ||
293 | ((struct group *)result)->gr_mem = members; | 298 | ((struct group *)result)->gr_mem = members; |
@@ -300,7 +305,7 @@ static void *convert_to_struct(struct passdb *db, | |||
300 | /* def "r" does nothing */ | 305 | /* def "r" does nothing */ |
301 | 306 | ||
302 | def++; | 307 | def++; |
303 | if (*def == '\0') | 308 | if ((unsigned char)*def < (unsigned char)' ') |
304 | break; | 309 | break; |
305 | buffer += strlen(buffer) + 1; | 310 | buffer += strlen(buffer) + 1; |
306 | } | 311 | } |