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

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


Ignore:
Timestamp:
2020-05-26T18:22:56Z (3 months ago)
Author:
Petr Pavlu <setup@…>
Branches:
master
Children:
f5a7773d
Parents:
145a13b
git-author:
Petr Pavlu <setup@…> (2020-05-25 20:47:43)
git-committer:
Petr Pavlu <setup@…> (2020-05-26 18:22:56)
Message:

Fix a NULL pointer access when boot components are uncompressed

When boot components are not compressed, their names do not have any
file extension. When checking whether a component is a GZIP file, code
in payload.c calls function isgzip(s) with `s' being a component name.
The name is passed to ext() which returns NULL if no extension is
present. The result is directly passed by isgzip() to str_cmp() and
would cause a NULL pointer access in the latter function.

Fix this by updating function isgzip() to check a result from the ext()
call. For consistency, update similarly function basename() in the same
file.

File:
1 edited

Legend:

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

    r145a13b rdf7dc9e  
    6161{
    6262        char *e = (char *) ext(s);
    63         if (str_cmp(e, ".gz") == 0)
     63        if (e != NULL && str_cmp(e, ".gz") == 0)
    6464                *e = '\0';
    6565}
     
    6767static bool isgzip(const char *s)
    6868{
    69         return str_cmp(ext(s), ".gz") == 0;
     69        const char *e = ext(s);
     70        return e != NULL && str_cmp(e, ".gz") == 0;
    7071}
    7172
Note: See TracChangeset for help on using the changeset viewer.