cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Fwd: Bug#310948: curl fails when HTTP response headers contain null bytes

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 30 May 2005 00:28:37 +0200 (CEST)

> ----- Forwarded message from Eric Cooper <ecc_at_cmu.edu> -----

> Here is a patch that seems to fix it, but I've only tested it with the site
> above.

Thanks for your report and patch. I would however instead suggest the
following patch. This is about to be committed to CVS just now.

--- lib/transfer.c 10 May 2005 23:02:37 -0000 1.279
+++ lib/transfer.c 29 May 2005 22:25:43 -0000
@@ -360,7 +360,7 @@
              /* str_start is start of line within buf */
              k->str_start = k->str;

- k->end_ptr = strchr (k->str_start, '\n');
+ k->end_ptr = memchr(k->str_start, '\n', nread);

              if (!k->end_ptr) {
                /* Not a complete header line within buffer, append the data to
@@ -428,7 +428,7 @@
              }

              /* copy to end of line */
- strncpy (k->hbufp, k->str_start, full_length);
+ memcpy(k->hbufp, k->str_start, full_length);
              k->hbufp += full_length;
              k->hbuflen += full_length;
              *k->hbufp = 0;

-- 
          -=- Daniel Stenberg -=- http://daniel.haxx.se -=-
   ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol
Received on 2005-05-30