Changeset d091007 in mainline for boot/generic/src/payload.c


Ignore:
Timestamp:
2021-06-04T16:58:15Z (3 years ago)
Author:
Martin Decky <martin@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3c8c580
Parents:
da15002
Message:

Detect a compressed component by GZIP signature, not file extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/generic/src/payload.c

    rda15002 rd091007  
    6161{
    6262        char *e = (char *) ext(s);
    63         if (e != NULL && str_cmp(e, ".gz") == 0)
     63        if ((e != NULL) && (str_cmp(e, ".gz") == 0))
    6464                *e = '\0';
    65 }
    66 
    67 static bool isgzip(const char *s)
    68 {
    69         const char *e = ext(s);
    70         return e != NULL && str_cmp(e, ".gz") == 0;
    7165}
    7266
     
    8276{
    8377        const char *name;
    84         const uint8_t *data;
    8578        size_t packed_size;
    86         size_t unpacked_size;
    8779
    8880        if (!tar_info(*cstart, cend, &name, &packed_size))
    8981                return false;
    9082
    91         data = *cstart + TAR_BLOCK_SIZE;
     83        const uint8_t *data = *cstart + TAR_BLOCK_SIZE;
    9284        *cstart += TAR_BLOCK_SIZE + ALIGN_UP(packed_size, TAR_BLOCK_SIZE);
    9385
    94         bool gz = isgzip(name);
    95 
    96         unpacked_size = gz ? gzip_size(data, packed_size) : packed_size;
     86        bool gz = gzip_check(data, packed_size);
     87        size_t unpacked_size = gz ? gzip_size(data, packed_size) : packed_size;
    9788
    9889        /* Components must be page-aligned. */
     
    156147        while (tar_info(start, payload_end, &name, &packed_size)) {
    157148                sz = ALIGN_UP(sz, PAGE_SIZE);
    158                 if (isgzip(name))
     149                if (gzip_check(start + TAR_BLOCK_SIZE, packed_size))
    159150                        sz += gzip_size(start + TAR_BLOCK_SIZE, packed_size);
    160151                else
Note: See TracChangeset for help on using the changeset viewer.