ar: read_num(): fix reading fields using the entire width
authorPeter Korsgaard <jacmet@sunsite.dk>
Tue, 10 Sep 2013 09:52:35 +0000 (11:52 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 10 Sep 2013 14:22:12 +0000 (16:22 +0200)
commit2a053a2430e8de2f5de3da7d4d25343f61161f09
treeecf4d1bc83b7f7ec3672758d81f3eec5a346246f
parentdc57294485068e644714804ad1b1a3a10c4fceec
ar: read_num(): fix reading fields using the entire width

ar fields are fixed length text strings (padded with spaces). Ensure
bb_strtou doesn't read past the field in case the full width is used.

The fields are only read once, so the simplest/smallest solution to me
seems to be to just pass the length to read_num() and then zero terminate
the string before passing it to bb_strtou. This does mean that the fields
MUST be read in reverse order, so some minor reshuffling was needed.

Bloat-o-meter:
function                                             old     new   delta
get_header_ar                                        394     414     +20
read_num                                              29      36      +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 27/0)               Total: 27 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
archival/libarchive/get_header_ar.c