From: hno <> Date: Fri, 25 Apr 2003 18:19:59 +0000 (+0000) Subject: Bug #605: memory corruption when processing DNS root labels causing X-Git-Tag: SQUID_3_0_PRE1~235 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4775d711a2b5c58878353714d8ba93c49e4f9ad4;p=thirdparty%2Fsquid.git Bug #605: memory corruption when processing DNS root labels causing segmentation faults on certain platforms (malloc library dependent) --- diff --git a/lib/rfc1035.c b/lib/rfc1035.c index 64d5f942ce..8e138538d6 100644 --- a/lib/rfc1035.c +++ b/lib/rfc1035.c @@ -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;