1
commit 4a16bd39866093f4949f8e9dc183fa2321bda22d
2
Author: Bernhard Walle <bernhard@bwalle.de>
3
Date: Mon Feb 22 08:56:33 2010 +0900
5
[PATCH] Fix buffer overflow when writing dh->signature.
7
Fix following compile warning when building with gcc 4.5 and with the
8
flags '-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables
9
-fasynchronous-unwind-tables -g -O2 -Wall'.
12
inlined from 'write_kdump_header' at makedumpfile.c:5457:8: \
13
/usr/include/bits/string3.h:107:3: warning: call to \
14
__builtin___strcpy_chk will always overflow destination buffer
16
Solution: Don't copy the terminating zero byte.
18
Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
20
diff --git a/makedumpfile.c b/makedumpfile.c
21
index 4fa6f50..855c718 100644
24
@@ -5454,7 +5454,7 @@ write_kdump_header(void)
28
- strcpy(dh->signature, KDUMP_SIGNATURE);
29
+ strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
30
dh->header_version = 3;
31
dh->block_size = info->page_size;
32
dh->sub_hdr_size = sizeof(kh) + info->size_vmcoreinfo;