]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
fix xstrncpy() bug
authorwessels <>
Sat, 23 Nov 1996 14:06:56 +0000 (14:06 +0000)
committerwessels <>
Sat, 23 Nov 1996 14:06:56 +0000 (14:06 +0000)
src/mime.cc

index 38bf5b8f9e9901eca2218cb22ae7e82a9caa07d4..35f7da7c7e7c6dca763785a31ba9d023f6184413 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: mime.cc,v 1.23 1996/11/22 08:38:51 wessels Exp $
+ * $Id: mime.cc,v 1.24 1996/11/23 07:06:56 wessels Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -116,6 +116,7 @@ mime_get_header(const char *mime, const char *name)
     char *q = NULL;
     char got = 0;
     int namelen = strlen(name);
+    int l;
 
     if (!mime || !name)
        return NULL;
@@ -131,7 +132,10 @@ mime_get_header(const char *mime, const char *name)
            continue;
        if (!isspace(p[namelen]) && p[namelen] != ':')
            continue;
-       xstrncpy(header, p, strcspn(p, "\n\r") + 1);
+       l = strcspn(p, "\n\r") + 1;
+       if (l > GET_HDR_SZ)
+               l = GET_HDR_SZ;
+       xstrncpy(header, p, l);
        debug(25, 5, "mime_get_header: checking '%s'\n", header);
        q = header;
        q += namelen;