Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b33d140 in mainline


Ignore:
Timestamp:
2017-08-26T21:59:30Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
8ebc5b8a
Parents:
ac415d50
Message:

GPT should check alt. header block address for sanity before trying to read it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/label/src/gpt.c

    rac415d50 rb33d140  
    9999        uint8_t *etable[2];
    100100        size_t bsize;
     101        aoff64_t nblocks;
    101102        uint32_t num_entries;
    102103        uint32_t esize;
     
    123124        }
    124125
     126        rc = bd->ops->get_nblocks(bd->arg, &nblocks);
     127        if (rc != EOK) {
     128                rc = EIO;
     129                goto error;
     130        }
     131
    125132        if (bsize < 512 || (bsize % 512) != 0) {
    126133                rc = EINVAL;
     
    147154
    148155        h1ba = uint64_t_le2host(gpt_hdr[0]->alternate_lba);
     156
     157        if (h1ba >= nblocks) {
     158                rc = EINVAL;
     159                goto error;
     160        }
    149161
    150162        rc = bd->ops->read(bd->arg, h1ba, 1, gpt_hdr[1]);
Note: See TracChangeset for help on using the changeset viewer.