diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-03 17:53:49 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-03 17:53:49 +0100 |
commit | 5e62a3d016633d4d97906f0f73298dc8e8b6a42b (patch) | |
tree | b0cdea416496237b3a15ea6f123371aff6168ecc /libpwdgrp | |
parent | 9dca6acaac3a49f1ff8ba9d3ca78853da6f59ae1 (diff) | |
download | busybox-w32-5e62a3d016633d4d97906f0f73298dc8e8b6a42b.tar.gz busybox-w32-5e62a3d016633d4d97906f0f73298dc8e8b6a42b.tar.bz2 busybox-w32-5e62a3d016633d4d97906f0f73298dc8e8b6a42b.zip |
libpwdgrp: use a better estimate of max struct size
Previous code's trick with bitwise OR was giving this on 32-bit x86:
sizeof(struct passwd):28
sizeof(struct group):16
sizeof(struct spwd):36
sizeof(struct_result):60
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libpwdgrp')
-rw-r--r-- | libpwdgrp/pwd_grp.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index 539d2b01f..f3fcec859 100644 --- a/libpwdgrp/pwd_grp.c +++ b/libpwdgrp/pwd_grp.c | |||
@@ -45,11 +45,10 @@ struct passdb { | |||
45 | uint8_t numfields; | 45 | uint8_t numfields; |
46 | FILE *fp; | 46 | FILE *fp; |
47 | char *malloced; | 47 | char *malloced; |
48 | char struct_result[0 | 48 | char struct_result[ |
49 | | sizeof(struct passwd) | 49 | /* Should be max(sizeof passwd,group,spwd), but this will do: */ |
50 | | sizeof(struct group) | 50 | IF_NOT_USE_BB_SHADOW(sizeof(struct passwd)) |
51 | IF_USE_BB_SHADOW( | sizeof(struct spwd) ) | 51 | IF_USE_BB_SHADOW(sizeof(struct spwd)) |
52 | /* bitwise OR above is poor man's max(a,b,c) */ | ||
53 | ]; | 52 | ]; |
54 | }; | 53 | }; |
55 | 54 | ||