[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] [PATCH 2/2] init_buffer: zero-fill allocated memory to prevent
From: |
Alexander Kolesen |
Subject: |
[Bug-tar] [PATCH 2/2] init_buffer: zero-fill allocated memory to prevent walking a junk |
Date: |
Thu, 2 Jan 2014 00:13:22 +0300 |
Need to zero-fill allocated memory returned by page_aligned_alloc
in case of initializing a new buffer for an archive.
Otherwise there's a chance of checksum error in case of checking compressed
files.
---
src/buffer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/buffer.c b/src/buffer.c
index 723ea71..cba54b2 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -626,9 +626,11 @@ xclose (int fd)
static void
init_buffer (void)
{
- if (! record_buffer_aligned[record_index])
+ if (! record_buffer_aligned[record_index]){
record_buffer_aligned[record_index] =
page_aligned_alloc (&record_buffer[record_index], record_size);
+ memset(record_buffer_aligned[record_index], 0, record_size);
+ }
record_start = record_buffer_aligned[record_index];
current_block = record_start;
--
1.8.5.2