aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/execute.c
diff options
context:
space:
mode:
authorSylvain Gault <sylvain.gault@gmail.com>2015-10-12 05:03:26 +0200
committerSylvain Gault <sylvain.gault@gmail.com>2015-10-13 05:44:33 +0200
commit7bb4e1335435397243c9b63a64a5c61c82691357 (patch)
tree9520abd28cf3b4107efac11fd573f6b1019979db /com32/elflink/ldlinux/execute.c
parent91463467e4633d7c29dfb98b4079c3c330fcde95 (diff)
downloadsyslinux-7bb4e1335435397243c9b63a64a5c61c82691357.tar.gz
syslinux-7bb4e1335435397243c9b63a64a5c61c82691357.tar.xz
syslinux-7bb4e1335435397243c9b63a64a5c61c82691357.zip
ldlinux: fix stack overflow when running COM32 modules
When a COM32 module exits, the functions never return and a new call to ldlinux_enter_command is made. This could fill the stack and overflow on some data present in memory. This patch use setjmp/longjmp to return to the main function and restart from there when a COM32 module exits. Signed-off-by: Sylvain Gault <sylvain.gault@gmail.com>
Diffstat (limited to 'com32/elflink/ldlinux/execute.c')
-rw-r--r--com32/elflink/ldlinux/execute.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 653c880d..39555715 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -44,6 +44,7 @@ const struct image_types image_boot_types[] = {
{ NULL, 0 },
};
+extern jmp_buf __return_to_command_prompt;
extern int create_args_and_load(char *);
__export void execute(const char *cmdline, uint32_t type, bool sysappend)
@@ -136,7 +137,8 @@ __export void execute(const char *cmdline, uint32_t type, bool sysappend)
/* Restore the console */
ldlinux_console_init();
- ldlinux_enter_command();
+ /* Jump back to the main to call ldlinux_enter_command */
+ longjmp(__return_to_command_prompt, 1);
} else if (type == IMAGE_TYPE_CONFIG) {
char *argv[] = { LDLINUX, NULL, NULL };
char *config;