Mem leak fix from Matt Kraai
This commit is contained in:
parent
483262f633
commit
f361ac29b0
6
lash.c
6
lash.c
@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog)
|
|||||||
|
|
||||||
static int getCommand(FILE * source, char *command)
|
static int getCommand(FILE * source, char *command)
|
||||||
{
|
{
|
||||||
char *user,buf[255],*s;
|
char user[9],buf[255],*s;
|
||||||
|
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
if (local_pending_command) {
|
if (local_pending_command) {
|
||||||
@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command)
|
|||||||
|
|
||||||
/* get User Name and setup prompt */
|
/* get User Name and setup prompt */
|
||||||
strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# ");
|
strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# ");
|
||||||
user=xcalloc(sizeof(int), 9);
|
|
||||||
my_getpwuid(user, geteuid());
|
my_getpwuid(user, geteuid());
|
||||||
|
|
||||||
/* get HostName */
|
/* get HostName */
|
||||||
@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't leak memory */
|
|
||||||
free(user);
|
|
||||||
|
|
||||||
if (!fgets(command, BUFSIZ - 2, source)) {
|
if (!fgets(command, BUFSIZ - 2, source)) {
|
||||||
if (source == stdin)
|
if (source == stdin)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
6
sh.c
6
sh.c
@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog)
|
|||||||
|
|
||||||
static int getCommand(FILE * source, char *command)
|
static int getCommand(FILE * source, char *command)
|
||||||
{
|
{
|
||||||
char *user,buf[255],*s;
|
char user[9],buf[255],*s;
|
||||||
|
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
if (local_pending_command) {
|
if (local_pending_command) {
|
||||||
@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command)
|
|||||||
|
|
||||||
/* get User Name and setup prompt */
|
/* get User Name and setup prompt */
|
||||||
strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# ");
|
strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# ");
|
||||||
user=xcalloc(sizeof(int), 9);
|
|
||||||
my_getpwuid(user, geteuid());
|
my_getpwuid(user, geteuid());
|
||||||
|
|
||||||
/* get HostName */
|
/* get HostName */
|
||||||
@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't leak memory */
|
|
||||||
free(user);
|
|
||||||
|
|
||||||
if (!fgets(command, BUFSIZ - 2, source)) {
|
if (!fgets(command, BUFSIZ - 2, source)) {
|
||||||
if (source == stdin)
|
if (source == stdin)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog)
|
|||||||
|
|
||||||
static int getCommand(FILE * source, char *command)
|
static int getCommand(FILE * source, char *command)
|
||||||
{
|
{
|
||||||
char *user,buf[255],*s;
|
char user[9],buf[255],*s;
|
||||||
|
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
if (local_pending_command) {
|
if (local_pending_command) {
|
||||||
@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command)
|
|||||||
|
|
||||||
/* get User Name and setup prompt */
|
/* get User Name and setup prompt */
|
||||||
strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# ");
|
strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# ");
|
||||||
user=xcalloc(sizeof(int), 9);
|
|
||||||
my_getpwuid(user, geteuid());
|
my_getpwuid(user, geteuid());
|
||||||
|
|
||||||
/* get HostName */
|
/* get HostName */
|
||||||
@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't leak memory */
|
|
||||||
free(user);
|
|
||||||
|
|
||||||
if (!fgets(command, BUFSIZ - 2, source)) {
|
if (!fgets(command, BUFSIZ - 2, source)) {
|
||||||
if (source == stdin)
|
if (source == stdin)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user