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

Michal Sojka sojkam1 at fel.cvut.cz
Thu Apr 1 05:05:06 PDT 2010


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


More information about the notmuch mailing list