Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/archival/libarchive/get_header_ar.c

    r3232 r3621  
    99#include "ar.h"
    1010
    11 static unsigned read_num(const char *str, int base)
     11/* WARNING: Clobbers str[len], so fields must be read in reverse order! */
     12static unsigned read_num(char *str, int base, int len)
    1213{
     14    int err;
     15
     16    /* ar fields are fixed length text strings (padded with spaces).
     17     * Ensure bb_strtou doesn't read past the field in case the full
     18     * width is used. */
     19    str[len] = 0;
     20
    1321    /* This code works because
    1422     * on misformatted numbers bb_strtou returns all-ones */
    15     int err = bb_strtou(str, NULL, base);
     23    err = bb_strtou(str, NULL, base);
    1624    if (err == -1)
    1725        bb_error_msg_and_die("invalid ar header");
     
    5260        bb_error_msg_and_die("invalid ar header");
    5361
    54     /* FIXME: more thorough routine would be in order here
    55      * (we have something like that in tar)
    56      * but for now we are lax. */
    57     ar.formatted.magic[0] = '\0'; /* else 4G-2 file will have size="4294967294`\n..." */
    58     typed->size = size = read_num(ar.formatted.size, 10);
     62    /*
     63     * Note that the fields MUST be read in reverse order as
     64     * read_num() clobbers the next byte after the field!
     65     * Order is: name, date, uid, gid, mode, size, magic.
     66     */
     67    typed->size = size = read_num(ar.formatted.size, 10,
     68                      sizeof(ar.formatted.size));
    5969
    6070    /* special filenames have '/' as the first character */
     
    8898     * after dealing with long filename pseudo file.
    8999     */
    90     typed->mode = read_num(ar.formatted.mode, 8);
    91     typed->mtime = read_num(ar.formatted.date, 10);
    92     typed->uid = read_num(ar.formatted.uid, 10);
    93     typed->gid = read_num(ar.formatted.gid, 10);
     100    typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode));
     101    typed->gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid));
     102    typed->uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid));
     103    typed->mtime = read_num(ar.formatted.date, 10, sizeof(ar.formatted.date));
    94104
    95105#if ENABLE_FEATURE_AR_LONG_FILENAMES
     
    99109        /* The number after the '/' indicates the offset in the ar data section
    100110         * (saved in ar_long_names) that conatains the real filename */
    101         long_offset = read_num(&ar.formatted.name[1], 10);
     111        long_offset = read_num(&ar.formatted.name[1], 10,
     112                       sizeof(ar.formatted.name) - 1);
    102113        if (long_offset >= ar_long_name_size) {
    103114            bb_error_msg_and_die("can't resolve long filename");
Note: See TracChangeset for help on using the changeset viewer.