summaryrefslogtreecommitdiff
path: root/debian/patches/bootshell0009-fixup-more-error-handling.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/bootshell0009-fixup-more-error-handling.patch')
-rw-r--r--debian/patches/bootshell0009-fixup-more-error-handling.patch70
1 files changed, 70 insertions, 0 deletions
diff --git a/debian/patches/bootshell0009-fixup-more-error-handling.patch b/debian/patches/bootshell0009-fixup-more-error-handling.patch
new file mode 100644
index 00000000..72d9a3a1
--- /dev/null
+++ b/debian/patches/bootshell0009-fixup-more-error-handling.patch
@@ -0,0 +1,70 @@
+From e88a341c9d13e5eac93b57890a980ded742aa8d4 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Mon, 9 Mar 2015 20:51:21 +0100
+Subject: [PATCH hurd 09/10] fixup more error handling
+
+---
+ bootshell/elf-exec.c | 23 +++++++++++++++++------
+ 1 file changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/bootshell/elf-exec.c b/bootshell/elf-exec.c
+index c8a8e14..a61addb 100644
+--- a/bootshell/elf-exec.c
++++ b/bootshell/elf-exec.c
+@@ -117,7 +117,10 @@ boot_script_exec_cmd (mach_port_t task, char *path, int argc,
+ arg_len += 5 * sizeof (int);
+ stack_end = VM_MAX_ADDRESS;
+ stack_start = VM_MAX_ADDRESS - 16 * 1024 * 1024;
+- vm_allocate (task, &stack_start, stack_end - stack_start, FALSE);
++ err = vm_allocate (task, &stack_start, stack_end - stack_start, FALSE);
++ if (err)
++ return err;
++
+ arg_pos = (void *) ((stack_end - arg_len) & ~(sizeof (natural_t) - 1));
+ args = mmap (0, stack_end - trunc_page ((vm_offset_t) arg_pos),
+ PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+@@ -137,12 +140,16 @@ boot_script_exec_cmd (mach_port_t task, char *path, int argc,
+ p = (void *) p + sizeof (char *);
+ memcpy (p, strings, stringlen);
+ memset (args, 0, (vm_offset_t)arg_pos & (vm_page_size - 1));
+- vm_write (task, trunc_page ((vm_offset_t) arg_pos), (vm_address_t) args,
+- stack_end - trunc_page ((vm_offset_t) arg_pos));
++ err = vm_write (task, trunc_page ((vm_offset_t) arg_pos), (vm_address_t) args,
++ stack_end - trunc_page ((vm_offset_t) arg_pos));
++ if (err)
++ return err;
+ munmap ((caddr_t) args,
+ stack_end - trunc_page ((vm_offset_t) arg_pos));
+
+- thread_create (task, &thread);
++ err = thread_create (task, &thread);
++ if (err)
++ return err;
+
+ #ifdef i386_THREAD_STATE_COUNT
+ {
+@@ -152,8 +159,10 @@ boot_script_exec_cmd (mach_port_t task, char *path, int argc,
+ (thread_state_t) &regs, &reg_size);
+ regs.eip = (int) startpc;
+ regs.uesp = (int) arg_pos;
+- thread_set_state (thread, i386_THREAD_STATE,
+- (thread_state_t) &regs, reg_size);
++ err = thread_set_state (thread, i386_THREAD_STATE,
++ (thread_state_t) &regs, reg_size);
++ if (err)
++ return err;
+ }
+ #else
+ # error needs to be ported
+@@ -177,6 +186,8 @@ elf_exec (mach_port_t task, char *argz, size_t argz_len)
+
+ argc = argz_count (argz, argz_len);
+ argv = malloc ((argc + 1) * sizeof *argv);
++ if (argv == NULL)
++ return ENOMEM;
+ argz_extract (argz, argz_len, argv);
+
+ err = boot_script_exec_cmd (task, argz, argc, argv, argz, argz_len);
+--
+2.1.4
+