diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-03-15 19:18:21 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-03-15 19:18:21 +0000 |
commit | 0d4e51d390b7118a4f2332834964e49de9469426 (patch) | |
tree | a81a8d6be9667bc43b83331d600a39647c44bc53 | |
parent | 0b57e28373550f7657bd4e026ae482806139885f (diff) | |
download | busybox-w32-0d4e51d390b7118a4f2332834964e49de9469426.tar.gz busybox-w32-0d4e51d390b7118a4f2332834964e49de9469426.tar.bz2 busybox-w32-0d4e51d390b7118a4f2332834964e49de9469426.zip |
Prevent init from potentially using already freed memory when
deleting an initAction, fixing a bug pointed out by Andreas Neuhaus
-Erik
-rw-r--r-- | init.c | 12 | ||||
-rw-r--r-- | init/init.c | 12 |
2 files changed, 12 insertions, 12 deletions
@@ -598,8 +598,8 @@ static void check_memory() | |||
598 | /* Run all commands to be run right before halt/reboot */ | 598 | /* Run all commands to be run right before halt/reboot */ |
599 | static void run_lastAction(void) | 599 | static void run_lastAction(void) |
600 | { | 600 | { |
601 | initAction *a; | 601 | initAction *a, *tmp; |
602 | for (a = initActionList; a; a = a->nextPtr) { | 602 | for (a = tmp = initActionList; a; a = tmp = tmp->nextPtr) { |
603 | if (a->action == CTRLALTDEL) { | 603 | if (a->action == CTRLALTDEL) { |
604 | waitfor(a->process, a->console, FALSE); | 604 | waitfor(a->process, a->console, FALSE); |
605 | delete_initAction(a); | 605 | delete_initAction(a); |
@@ -843,7 +843,7 @@ static void parse_inittab(void) | |||
843 | 843 | ||
844 | extern int init_main(int argc, char **argv) | 844 | extern int init_main(int argc, char **argv) |
845 | { | 845 | { |
846 | initAction *a; | 846 | initAction *a, *tmp; |
847 | pid_t wpid; | 847 | pid_t wpid; |
848 | int status; | 848 | int status; |
849 | 849 | ||
@@ -938,7 +938,7 @@ extern int init_main(int argc, char **argv) | |||
938 | /* Now run everything that needs to be run */ | 938 | /* Now run everything that needs to be run */ |
939 | 939 | ||
940 | /* First run the sysinit command */ | 940 | /* First run the sysinit command */ |
941 | for (a = initActionList; a; a = a->nextPtr) { | 941 | for (a = tmp = initActionList; a; a = tmp = tmp->nextPtr) { |
942 | if (a->action == SYSINIT) { | 942 | if (a->action == SYSINIT) { |
943 | waitfor(a->process, a->console, FALSE); | 943 | waitfor(a->process, a->console, FALSE); |
944 | /* Now remove the "sysinit" entry from the list */ | 944 | /* Now remove the "sysinit" entry from the list */ |
@@ -946,7 +946,7 @@ extern int init_main(int argc, char **argv) | |||
946 | } | 946 | } |
947 | } | 947 | } |
948 | /* Next run anything that wants to block */ | 948 | /* Next run anything that wants to block */ |
949 | for (a = initActionList; a; a = a->nextPtr) { | 949 | for (a = tmp = initActionList; a; a = tmp = tmp->nextPtr) { |
950 | if (a->action == WAIT) { | 950 | if (a->action == WAIT) { |
951 | waitfor(a->process, a->console, FALSE); | 951 | waitfor(a->process, a->console, FALSE); |
952 | /* Now remove the "wait" entry from the list */ | 952 | /* Now remove the "wait" entry from the list */ |
@@ -954,7 +954,7 @@ extern int init_main(int argc, char **argv) | |||
954 | } | 954 | } |
955 | } | 955 | } |
956 | /* Next run anything to be run only once */ | 956 | /* Next run anything to be run only once */ |
957 | for (a = initActionList; a; a = a->nextPtr) { | 957 | for (a = tmp = initActionList; a; a = tmp = tmp->nextPtr) { |
958 | if (a->action == ONCE) { | 958 | if (a->action == ONCE) { |
959 | run(a->process, a->console, FALSE); | 959 | run(a->process, a->console, FALSE); |
960 | /* Now remove the "once" entry from the list */ | 960 | /* Now remove the "once" entry from the list */ |
diff --git a/init/init.c b/init/init.c index 53e9744c5..eb1b2c505 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -598,8 +598,8 @@ static void check_memory() | |||
598 | /* Run all commands to be run right before halt/reboot */ | 598 | /* Run all commands to be run right before halt/reboot */ |
599 | static void run_lastAction(void) | 599 | static void run_lastAction(void) |
600 | { | 600 | { |
601 | initAction *a; | 601 | initAction *a, *tmp; |
602 | for (a = initActionList; a; a = a->nextPtr) { | 602 | for (a = tmp = initActionList; a; a = tmp = tmp->nextPtr) { |
603 | if (a->action == CTRLALTDEL) { | 603 | if (a->action == CTRLALTDEL) { |
604 | waitfor(a->process, a->console, FALSE); | 604 | waitfor(a->process, a->console, FALSE); |
605 | delete_initAction(a); | 605 | delete_initAction(a); |
@@ -843,7 +843,7 @@ static void parse_inittab(void) | |||
843 | 843 | ||
844 | extern int init_main(int argc, char **argv) | 844 | extern int init_main(int argc, char **argv) |
845 | { | 845 | { |
846 | initAction *a; | 846 | initAction *a, *tmp; |
847 | pid_t wpid; | 847 | pid_t wpid; |
848 | int status; | 848 | int status; |
849 | 849 | ||
@@ -938,7 +938,7 @@ extern int init_main(int argc, char **argv) | |||
938 | /* Now run everything that needs to be run */ | 938 | /* Now run everything that needs to be run */ |
939 | 939 | ||
940 | /* First run the sysinit command */ | 940 | /* First run the sysinit command */ |
941 | for (a = initActionList; a; a = a->nextPtr) { | 941 | for (a = tmp = initActionList; a; a = tmp = tmp->nextPtr) { |
942 | if (a->action == SYSINIT) { | 942 | if (a->action == SYSINIT) { |
943 | waitfor(a->process, a->console, FALSE); | 943 | waitfor(a->process, a->console, FALSE); |
944 | /* Now remove the "sysinit" entry from the list */ | 944 | /* Now remove the "sysinit" entry from the list */ |
@@ -946,7 +946,7 @@ extern int init_main(int argc, char **argv) | |||
946 | } | 946 | } |
947 | } | 947 | } |
948 | /* Next run anything that wants to block */ | 948 | /* Next run anything that wants to block */ |
949 | for (a = initActionList; a; a = a->nextPtr) { | 949 | for (a = tmp = initActionList; a; a = tmp = tmp->nextPtr) { |
950 | if (a->action == WAIT) { | 950 | if (a->action == WAIT) { |
951 | waitfor(a->process, a->console, FALSE); | 951 | waitfor(a->process, a->console, FALSE); |
952 | /* Now remove the "wait" entry from the list */ | 952 | /* Now remove the "wait" entry from the list */ |
@@ -954,7 +954,7 @@ extern int init_main(int argc, char **argv) | |||
954 | } | 954 | } |
955 | } | 955 | } |
956 | /* Next run anything to be run only once */ | 956 | /* Next run anything to be run only once */ |
957 | for (a = initActionList; a; a = a->nextPtr) { | 957 | for (a = tmp = initActionList; a; a = tmp = tmp->nextPtr) { |
958 | if (a->action == ONCE) { | 958 | if (a->action == ONCE) { |
959 | run(a->process, a->console, FALSE); | 959 | run(a->process, a->console, FALSE); |
960 | /* Now remove the "once" entry from the list */ | 960 | /* Now remove the "once" entry from the list */ |