cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Crash using WRITEDATA callback depending on CUSTOMREQUEST sent!

From: Gonzalo Diethelm <gonzalo.diethelm_at_diethelm.org>
Date: Thu, 15 Mar 2007 08:09:57 -0400

On Wed, 2007-03-14 at 15:35 +0200, Arnaud Maye wrote:

> size_t ShellUpdater::WriteData(void *buffer, size_t size, size_t nmemb,
> void *userp)
> {
> char *data = (char *)buffer;
>
> strcat_s(gData, 600, data);
> return size * nmemb;
> }

I believe strcat_s() requires its first and third element to be
null-terminated. There are no guarantees about that being the case for
the buffer passed into your WRITEDATA function. Better switch that to a
plain memcpy(), which, in addition, is more portable.

Best regards,

-- 
Gonzalo Diethelm
gonzalo.diethelm_at_diethelm.org
Received on 2007-03-15