[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>
This commit is contained in:
parent
720d150c48
commit
2c865d9aa7
@ -462,6 +462,13 @@ static int ce_flush(SHA_CTX *context, int fd)
|
|||||||
SHA1_Update(context, write_buffer, left);
|
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 */
|
/* Append the SHA1 signature at the end */
|
||||||
SHA1_Final(write_buffer + left, context);
|
SHA1_Final(write_buffer + left, context);
|
||||||
left += 20;
|
left += 20;
|
||||||
|
Loading…
Reference in New Issue
Block a user