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

Changeset aa865ee in mainline


Ignore:
Timestamp:
2011-07-25T21:18:48Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
3fb0fec, ceb890b
Parents:
c566782
Message:

Check against end of file when reading ELF.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/elf/elf_load.c

    rc566782 raa865ee  
    148148
    149149        rc = read_all(elf->fd, header, sizeof(elf_header_t));
    150         if (rc < 0) {
     150        if (rc != sizeof(elf_header_t)) {
    151151                DPRINTF("Read error.\n");
    152152                return EE_INVALID;
     
    211211                rc = read_all(elf->fd, &segment_hdr,
    212212                    sizeof(elf_segment_header_t));
    213                 if (rc < 0) {
     213                if (rc != sizeof(elf_segment_header_t)) {
    214214                        DPRINTF("Read error.\n");
    215215                        return EE_INVALID;
     
    233233                rc = read_all(elf->fd, &section_hdr,
    234234                    sizeof(elf_section_header_t));
    235                 if (rc < 0) {
     235                if (rc != sizeof(elf_section_header_t)) {
    236236                        DPRINTF("Read error.\n");
    237237                        return EE_INVALID;
     
    321321        uintptr_t seg_addr;
    322322        size_t mem_sz;
    323         int rc;
     323        ssize_t rc;
    324324
    325325        bias = elf->bias;
     
    401401                rc = read_all(elf->fd, dp, now);
    402402
    403                 if (rc < 0) {
     403                if (rc != (ssize_t) now) {
    404404                        DPRINTF("Read error.\n");
    405405                        return EE_INVALID;
Note: See TracChangeset for help on using the changeset viewer.