]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #605: memory corruption when processing DNS root labels causing
authorhno <>
Fri, 25 Apr 2003 18:19:59 +0000 (18:19 +0000)
committerhno <>
Fri, 25 Apr 2003 18:19:59 +0000 (18:19 +0000)
segmentation faults on certain platforms (malloc library dependent)

lib/rfc1035.c

index 64d5f942ce20ee0e08467061125f4ba2df7f1f64..8e138538d605c76cc3c2063e290d0e57f430d6a7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: rfc1035.c,v 1.29 2003/01/23 00:37:01 robertc Exp $
+ * $Id: rfc1035.c,v 1.30 2003/04/25 12:19:59 hno Exp $
  *
  * Low level DNS protocol routines
  * AUTHOR: Duane Wessels
@@ -345,7 +345,10 @@ rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns
            *(name + (no++)) = '.';
        }
     } while (c > 0 && no < ns);
-    *(name + no - 1) = '\0';
+    if (no)
+       *(name + no - 1) = '\0';
+    else
+       *name = '\0';
     /* make sure we didn't allow someone to overflow the name buffer */
     assert(no <= ns);
     return 0;