[Freeipa-devel] [PATCH 0062] Prevent memory read outside allocated space in str_alloc()

Adam Tkac atkac at redhat.com
Mon Sep 24 12:08:08 UTC 2012


On Fri, Sep 14, 2012 at 10:50:56AM +0200, Petr Spacek wrote:
> Hello,
> 
> Prevent memory read outside allocated space in str_alloc().
> 
> Found by Valgrind during nsupdate stress test.

Ack

> From c53ec9cf2cc22e29630767b6b2259d145192ff62 Mon Sep 17 00:00:00 2001
> From: Petr Spacek <pspacek at redhat.com>
> Date: Fri, 14 Sep 2012 10:48:04 +0200
> Subject: [PATCH] Prevent memory read outside allocated space in str_alloc().
> 
> Signed-off-by: Petr Spacek <pspacek at redhat.com>
> ---
>  src/str.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/str.c b/src/str.c
> index 0096536de071f7d0dd2ff327e4d6ac72e81dab5f..83645365ee6eff7bda5fbeda6837f30d4dec41ae 100644
> --- a/src/str.c
> +++ b/src/str.c
> @@ -102,7 +102,7 @@ str_alloc(ld_string_t *str, size_t len)
>  		return ISC_R_NOMEMORY;
>  
>  	if (str->data != NULL) {
> -		memcpy(new_buffer, str->data, len);
> +		memcpy(new_buffer, str->data, str->allocated);
>  		new_buffer[len] = '\0';
>  		isc_mem_put(str->mctx, str->data, str->allocated);
>  	} else {
> -- 
> 1.7.11.4
> 


-- 
Adam Tkac, Red Hat, Inc.




More information about the Freeipa-devel mailing list