* direntry.c (vfs_s_get_line): Fix off-by-one buffer overflow.

This commit is contained in:
Pavel Roskin 2002-08-20 01:08:34 +00:00
parent 9a36e62af2
commit 1c411834a8
2 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,7 @@
2002-08-19 Pavel Roskin <proski@gnu.org> 2002-08-19 Pavel Roskin <proski@gnu.org>
* direntry.c (vfs_s_get_line): Fix off-by-one buffer overflow.
* fish.c (pipeopen): Use _exit(), not vfs_die() to terminate the * fish.c (pipeopen): Use _exit(), not vfs_die() to terminate the
child if execvp() fails. child if execvp() fails.

View File

@ -1134,7 +1134,7 @@ vfs_s_get_line (vfs *me, int sock, char *buf, int buf_len, char term)
int i, status; int i, status;
char c; char c;
for (i = 0; i < buf_len; i++, buf++){ for (i = 0; i < buf_len - 1; i++, buf++){
if (read (sock, buf, sizeof(char)) <= 0) if (read (sock, buf, sizeof(char)) <= 0)
return 0; return 0;
if (logfile){ if (logfile){
@ -1146,6 +1146,8 @@ vfs_s_get_line (vfs *me, int sock, char *buf, int buf_len, char term)
return 1; return 1;
} }
} }
/* Line is too long - terminate buffer and discard the rest of line */
*buf = 0; *buf = 0;
while ((status = read (sock, &c, sizeof (c))) > 0){ while ((status = read (sock, &c, sizeof (c))) > 0){
if (logfile){ if (logfile){