From 8c355b08895c92abe5fe4ecbe0f34f3cfb94ea1a Mon Sep 17 00:00:00 2001 From: Colin Percival Date: Thu, 18 Nov 2004 12:01:30 +0000 Subject: [PATCH] Fix buffer overflow. This is FreeBSD-SA-04:16.fetch. Approved by: des --- usr.bin/fetch/fetch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index ffcbc43d05d..2834e0b5902 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -584,7 +584,8 @@ fetch(char *URL, const char *path) /* suck in the data */ signal(SIGINFO, sig_handler); while (!sigint) { - if (us.size != -1 && us.size - count < B_size) + if (us.size != -1 && us.size - count < B_size && + us.size - count >= 0) size = us.size - count; else size = B_size;