Re: [notmuch] [PATCH] format_part_json: part_content->data is not null terminated

Subject: Re: [notmuch] [PATCH] format_part_json: part_content->data is not null terminated

Date: Thu, 01 Apr 2010 14:05:06 +0200

To: David Edmondson, David Bremner, Gregor Hoffleit, notmuch

Cc:

From: Michal Sojka


On Thu, 04 Mar 2010, Gregor Hoffleit wrote:
> -	printf (", \"content\": %s", json_quote_str (ctx, (char *) part_content->data));
> +	content_data = talloc_size (ctx, part_content->len+1);
> +	memcpy (content_data, (char *)part_content->data, part_content->len+1);
> +	content_data[part_content->len] = 0;
> +	printf (", \"content\": %s", json_quote_str (ctx, content_data));

What about modifying json_quote_str() to accept additional parameter
len? If I have 10MB attachment to the email, this unnecessary copy is
quite expensive, isn't it?

--Michal

Thread: