[dm-devel] [PATCH 02/12] Return the correct size buffer in set_value()
Christophe Varoqui
christophe.varoqui at opensvc.com
Tue Jul 1 18:47:36 UTC 2014
Applied.
Thanks.
On Mon, Jun 30, 2014 at 7:13 AM, Benjamin Marzinski <bmarzins at redhat.com>
wrote:
> When multipath was mallocing the buffer in set_value, it was using
> sizeof(char *), instead of sizeof(char), so it was allocating a buffer
> big enough for an array of pointers instead of characters.
>
> Signed-off-by: Benjamin Marzinski <bmarzins at redhat.com>
> ---
> libmultipath/parser.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libmultipath/parser.c b/libmultipath/parser.c
> index 526c45b..0d4c870 100644
> --- a/libmultipath/parser.c
> +++ b/libmultipath/parser.c
> @@ -408,11 +408,11 @@ set_value(vector strvec)
> len += strlen(str);
> if (!alloc)
> alloc =
> - (char *) MALLOC(sizeof (char *) *
> + (char *) MALLOC(sizeof (char) *
> (len + 1));
> else {
> alloc =
> - REALLOC(alloc, sizeof (char *) * (len
> + 1));
> + REALLOC(alloc, sizeof (char) * (len +
> 1));
> tmp = VECTOR_SLOT(strvec, i-1);
> if (alloc && *str != '"' && *tmp != '"')
> strncat(alloc, " ", 1);
> @@ -422,7 +422,7 @@ set_value(vector strvec)
> strncat(alloc, str, strlen(str));
> }
> } else {
> - alloc = MALLOC(sizeof (char *) * (size + 1));
> + alloc = MALLOC(sizeof (char) * (size + 1));
> if (alloc)
> memcpy(alloc, str, size);
> }
> --
> 1.8.3.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20140701/b4694db2/attachment.htm>
More information about the dm-devel
mailing list