ssh-upload: prevent buffer overrun

Prevent a client from overrunning the on stack ref buffer.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Andy Whitcroft
2007-01-08 11:45:44 +00:00
committed by Junio C Hamano
parent 4083c2fce8
commit d677db86d9

View File

@ -67,7 +67,7 @@ static int serve_ref(int fd_in, int fd_out)
int posn = 0; int posn = 0;
signed char remote = 0; signed char remote = 0;
do { do {
if (read(fd_in, ref + posn, 1) < 1) if (posn >= PATH_MAX || read(fd_in, ref + posn, 1) < 1)
return -1; return -1;
posn++; posn++;
} while (ref[posn - 1]); } while (ref[posn - 1]);