On 31/08/11 10:55, Alex Rousskov wrote:
On 08/30/2011 09:51 AM, Amos Jeffries wrote:

+        if (IsIPv6())
+            memcpy(buf,"::\0", min(static_cast<unsigned int>(3),blen));
+        else if (IsIPv4())
+            memcpy(buf,"0.0.0.0\0", min(static_cast<unsigned int>(8),blen));

There should be no reason to put a second 0-terminator into a
"guaranteed to be 0-terminated" string constant.

That one is there to ensure the destination ends up nul-terminated when blen is larger without having to dicker around with 4 extra lines of code calculating the amount copied and assigning the final byte separately and without the xstrncpy additional padding being written.

We seem not to be allowed to memcpy(dst, "::", 3) for some reason despite as you say, the termination guarantee.

Amos
--
Please be using
  Current Stable Squid 2.7.STABLE9 or 3.1.15
  Beta testers wanted for 3.2.0.10

Reply via email to