]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Let strlcpy() do the truncation check.
authorGuy Harris <[email protected]>
Sun, 7 Aug 2016 23:55:08 +0000 (16:55 -0700)
committerGuy Harris <[email protected]>
Sun, 7 Aug 2016 23:55:08 +0000 (16:55 -0700)
addrtostr.c

index 1ea792adc97451c55e6b1fe29291229faa59cf81..caea1775b2fa87b83aa60a1355f6459fc9fbd94e 100644 (file)
@@ -188,12 +188,12 @@ addrtostr6 (const void *src, char *dst, size_t size)
      *tp++ = ':';
   *tp++ = '\0';
 
-  /* Check for overflow, copy, and we're done.
+  /* Copy and check for overflow.
    */
-  if ((size_t)(tp - tmp) > size)
+  if (strlcpy (dst, tmp, size) >= size)
   {
     errno = ENOSPC;
     return (NULL);
   }
-  return strcpy (dst, tmp);
+  return (dst);
 }