Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQingning Huo <qhuo@mayhq.co.uk>2005-09-11 17:27:47 +0400
committerJunio C Hamano <junkio@cox.net>2005-09-11 21:51:13 +0400
commit2c865d9aa7b9c3511f901b2544b667c5188f510e (patch)
tree3df04617960fd4dbd7aa2378f5fb7e50583f0142
parent720d150c48fc35fca13c6dfb3c76d60e4ee83b87 (diff)
[PATCH] Fix buffer overflow in ce_flush().
Add a check before appending SHA1 signature to write_buffer, flush it first if necessary. Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--read-cache.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index ced597318e..6eff4c8401 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -462,6 +462,13 @@ static int ce_flush(SHA_CTX *context, int fd)
SHA1_Update(context, write_buffer, left);
}
+ /* Flush first if not enough space for SHA1 signature */
+ if (left + 20 > WRITE_BUFFER_SIZE) {
+ if (write(fd, write_buffer, left) != left)
+ return -1;
+ left = 0;
+ }
+
/* Append the SHA1 signature at the end */
SHA1_Final(write_buffer + left, context);
left += 20;