1.1 --- a/libexec/include/exec/elf.h Mon Jun 06 01:02:59 2022 +0200
1.2 +++ b/libexec/include/exec/elf.h Tue Jun 07 01:14:05 2022 +0200
1.3 @@ -83,7 +83,7 @@
1.4
1.5 /* Return the appropriate payload object. */
1.6
1.7 -Payload *get_payload(char *buf);
1.8 +Payload *exec_open_payload(char *buf);
1.9
1.10 /* vim: tabstop=2 expandtab shiftwidth=2
1.11 */
2.1 --- a/libexec/lib/src/elf.cc Mon Jun 06 01:02:59 2022 +0200
2.2 +++ b/libexec/lib/src/elf.cc Tue Jun 07 01:14:05 2022 +0200
2.3 @@ -162,7 +162,7 @@
2.4
2.5 /* Return the appropriate payload object. */
2.6
2.7 -Payload *get_payload(char *buf)
2.8 +Payload *exec_open_payload(char *buf)
2.9 {
2.10 switch (buf[EI_CLASS])
2.11 {
3.1 --- a/libexec/lib/src/memory.cc Mon Jun 06 01:02:59 2022 +0200
3.2 +++ b/libexec/lib/src/memory.cc Tue Jun 07 01:14:05 2022 +0200
3.3 @@ -52,12 +52,18 @@
3.4 /* Attempt to get a payload object appropriate for a particular object size
3.5 variant. */
3.6
3.7 - *payload = get_payload(buf);
3.8 + *payload = exec_open_payload(buf);
3.9 +
3.10 + if (*payload == NULL)
3.11 + return -L4_ERANGE;
3.12
3.13 - if ((*payload == NULL) ||
3.14 - (file->size < (*payload)->header_extent()) ||
3.15 + if ((file->size < (*payload)->header_extent()) ||
3.16 (file->size < (*payload)->program_header_extent()))
3.17 - return -L4_ERANGE;
3.18 + {
3.19 + delete *payload;
3.20 + *payload = NULL;
3.21 + return -L4_EIO;
3.22 + }
3.23
3.24 /* Obtain all loadable segments. */
3.25
3.26 @@ -74,7 +80,11 @@
3.27 file_t *rfile = client_open(filename, file_opening_flags(segment->region_flags()));
3.28
3.29 if (rfile == NULL)
3.30 + {
3.31 + delete *payload;
3.32 + *payload = NULL;
3.33 return -L4_EIO;
3.34 + }
3.35
3.36 err = segment->fill(rfile);
3.37 }
3.38 @@ -82,7 +92,11 @@
3.39 err = segment->allocate();
3.40
3.41 if (err)
3.42 + {
3.43 + delete *payload;
3.44 + *payload = NULL;
3.45 return err;
3.46 + }
3.47 }
3.48
3.49 return L4_EOK;