From: serassio <> Date: Sun, 23 Jan 2005 21:55:45 +0000 (+0000) Subject: Bug #1197: DNS related memory leak on certain malformed DNS responses X-Git-Tag: SQUID_3_0_PRE4~895 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d443933d9874260e1034a9405b5065ca852f93a0;p=thirdparty%2Fsquid.git Bug #1197: DNS related memory leak on certain malformed DNS responses --- diff --git a/lib/rfc1035.c b/lib/rfc1035.c index f0c9417cad..05db4762fa 100644 --- a/lib/rfc1035.c +++ b/lib/rfc1035.c @@ -1,6 +1,6 @@ /* - * $Id: rfc1035.c,v 1.33 2005/01/23 14:53:23 serassio Exp $ + * $Id: rfc1035.c,v 1.34 2005/01/23 14:55:45 serassio Exp $ * * Low level DNS protocol routines * AUTHOR: Duane Wessels @@ -554,11 +554,10 @@ rfc1035AnswersUnpack(const char *buf, return -rfc1035_unpack_error; } } - i = (int) hdr.ancount; - if (i == 0) + if (hdr.ancount == 0) return 0; - recs = calloc(i, sizeof(*recs)); - while (i--) { + recs = calloc((int)hdr.ancount, sizeof(*recs)); + for (i = 0; i < (int)hdr.ancount; i++) { if (off >= sz) { /* corrupt packet */ RFC1035_UNPACK_DEBUG; break;