diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-12-12 23:45:36 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-12-12 23:45:36 +0000 |
commit | f361ac29b0f94c85a8aeb1185301f8197f64fe42 (patch) | |
tree | 8c0b218f0ea3f30822a66001ce72bdfe669d825f | |
parent | 483262f633837f98c02261fb035dd25845cbe893 (diff) | |
download | busybox-w32-f361ac29b0f94c85a8aeb1185301f8197f64fe42.tar.gz busybox-w32-f361ac29b0f94c85a8aeb1185301f8197f64fe42.tar.bz2 busybox-w32-f361ac29b0f94c85a8aeb1185301f8197f64fe42.zip |
Mem leak fix from Matt Kraai
-rw-r--r-- | lash.c | 6 | ||||
-rw-r--r-- | sh.c | 6 | ||||
-rw-r--r-- | shell/lash.c | 6 |
3 files changed, 3 insertions, 15 deletions
@@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog) | |||
663 | 663 | ||
664 | static int getCommand(FILE * source, char *command) | 664 | static int getCommand(FILE * source, char *command) |
665 | { | 665 | { |
666 | char *user,buf[255],*s; | 666 | char user[9],buf[255],*s; |
667 | 667 | ||
668 | if (source == NULL) { | 668 | if (source == NULL) { |
669 | if (local_pending_command) { | 669 | if (local_pending_command) { |
@@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command) | |||
678 | 678 | ||
679 | /* get User Name and setup prompt */ | 679 | /* get User Name and setup prompt */ |
680 | strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); | 680 | strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); |
681 | user=xcalloc(sizeof(int), 9); | ||
682 | my_getpwuid(user, geteuid()); | 681 | my_getpwuid(user, geteuid()); |
683 | 682 | ||
684 | /* get HostName */ | 683 | /* get HostName */ |
@@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command) | |||
723 | #endif | 722 | #endif |
724 | } | 723 | } |
725 | 724 | ||
726 | /* don't leak memory */ | ||
727 | free(user); | ||
728 | |||
729 | if (!fgets(command, BUFSIZ - 2, source)) { | 725 | if (!fgets(command, BUFSIZ - 2, source)) { |
730 | if (source == stdin) | 726 | if (source == stdin) |
731 | printf("\n"); | 727 | printf("\n"); |
@@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog) | |||
663 | 663 | ||
664 | static int getCommand(FILE * source, char *command) | 664 | static int getCommand(FILE * source, char *command) |
665 | { | 665 | { |
666 | char *user,buf[255],*s; | 666 | char user[9],buf[255],*s; |
667 | 667 | ||
668 | if (source == NULL) { | 668 | if (source == NULL) { |
669 | if (local_pending_command) { | 669 | if (local_pending_command) { |
@@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command) | |||
678 | 678 | ||
679 | /* get User Name and setup prompt */ | 679 | /* get User Name and setup prompt */ |
680 | strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); | 680 | strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); |
681 | user=xcalloc(sizeof(int), 9); | ||
682 | my_getpwuid(user, geteuid()); | 681 | my_getpwuid(user, geteuid()); |
683 | 682 | ||
684 | /* get HostName */ | 683 | /* get HostName */ |
@@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command) | |||
723 | #endif | 722 | #endif |
724 | } | 723 | } |
725 | 724 | ||
726 | /* don't leak memory */ | ||
727 | free(user); | ||
728 | |||
729 | if (!fgets(command, BUFSIZ - 2, source)) { | 725 | if (!fgets(command, BUFSIZ - 2, source)) { |
730 | if (source == stdin) | 726 | if (source == stdin) |
731 | printf("\n"); | 727 | printf("\n"); |
diff --git a/shell/lash.c b/shell/lash.c index 9fc215c98..164d6f5c5 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog) | |||
663 | 663 | ||
664 | static int getCommand(FILE * source, char *command) | 664 | static int getCommand(FILE * source, char *command) |
665 | { | 665 | { |
666 | char *user,buf[255],*s; | 666 | char user[9],buf[255],*s; |
667 | 667 | ||
668 | if (source == NULL) { | 668 | if (source == NULL) { |
669 | if (local_pending_command) { | 669 | if (local_pending_command) { |
@@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command) | |||
678 | 678 | ||
679 | /* get User Name and setup prompt */ | 679 | /* get User Name and setup prompt */ |
680 | strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); | 680 | strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); |
681 | user=xcalloc(sizeof(int), 9); | ||
682 | my_getpwuid(user, geteuid()); | 681 | my_getpwuid(user, geteuid()); |
683 | 682 | ||
684 | /* get HostName */ | 683 | /* get HostName */ |
@@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command) | |||
723 | #endif | 722 | #endif |
724 | } | 723 | } |
725 | 724 | ||
726 | /* don't leak memory */ | ||
727 | free(user); | ||
728 | |||
729 | if (!fgets(command, BUFSIZ - 2, source)) { | 725 | if (!fgets(command, BUFSIZ - 2, source)) { |
730 | if (source == stdin) | 726 | if (source == stdin) |
731 | printf("\n"); | 727 | printf("\n"); |