malloc over fatty buffers

This commit is contained in:
Roy Marples
2007-10-12 00:01:33 +00:00
parent e3bc6666d6
commit 20a149b2c7
10 changed files with 95 additions and 69 deletions

View File

@ -376,7 +376,7 @@ static bool svc_exec (const char *arg1, const char *arg2)
int flags = 0;
fd_set rset;
int s;
char buffer[RC_LINEBUFFER];
char *buffer;
size_t bytes;
bool prefixed = false;
int selfd;
@ -437,6 +437,7 @@ static bool svc_exec (const char *arg1, const char *arg2)
}
selfd = MAX (master_tty, signal_pipe[0]) + 1;
buffer = xmalloc (sizeof (char) * RC_LINEBUFFER);
while (1) {
FD_ZERO (&rset);
FD_SET (signal_pipe[0], &rset);
@ -456,12 +457,13 @@ static bool svc_exec (const char *arg1, const char *arg2)
break;
if (master_tty >= 0 && FD_ISSET (master_tty, &rset)) {
bytes = read (master_tty, buffer, sizeof (buffer));
bytes = read (master_tty, buffer, RC_LINEBUFFER);
write_prefix (buffer, bytes, &prefixed);
}
}
}
free (buffer);
close (signal_pipe[0]);
close (signal_pipe[1]);
signal_pipe[0] = signal_pipe[1] = -1;