[PATCH] Fix buffer overflow when writing dh->signature

Ken'ichi Ohmichi oomichi at mxs.nes.nec.co.jp
Sun Feb 21 19:04:09 EST 2010


Hi Bernhard,

Thank you for your patch.
The patch is good for me, and it has been merged into the git tree.

http://makedumpfile.git.sourceforge.net/git/gitweb.cgi?p=makedumpfile/makedumpfile;a=summary


Thanks
Ken'ichi Ohmichi

Bernhard Walle wrote:
> Fix following compile warning when building with gcc 4.5 and with the
> flags '-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables
> -fasynchronous-unwind-tables -g -O2 -Wall'.
> 
>   In function 'strcpy',
>       inlined from 'write_kdump_header' at makedumpfile.c:5457:8: \
>       /usr/include/bits/string3.h:107:3: warning: call to \
>       __builtin___strcpy_chk will always overflow destination buffer
> 
> Solution: Don't copy the terminating zero byte.
> 
> Signed-off-by: Bernhard Walle <bernhard at bwalle.de>
> ---
>  makedumpfile.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/makedumpfile.c b/makedumpfile.c
> index 4fa6f50..855c718 100644
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -5454,7 +5454,7 @@ write_kdump_header(void)
>  	/*
>  	 * Write common header
>  	 */
> -	strcpy(dh->signature, KDUMP_SIGNATURE);
> +	strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
>  	dh->header_version = 3;
>    	dh->block_size     = info->page_size;
>  	dh->sub_hdr_size   = sizeof(kh) + info->size_vmcoreinfo;




More information about the kexec mailing list