[Pkg-telepathy-commits] [libnice] 31/265: stun: Explicitly avoid a memcpy() from NULL

Simon McVittie smcv at debian.org
Wed May 14 12:04:49 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository libnice.

commit 869093b34758646d915ef06a2473aa0b2c7432d1
Author: Philip Withnall <philip.withnall at collabora.co.uk>
Date:   Tue Dec 17 09:54:01 2013 +0000

    stun: Explicitly avoid a memcpy() from NULL
    
    If stun_message_append_bytes() is called through
    stun_message_append_flag(), data will be NULL and len will be 0. This
    will result in a memcpy(ptr, NULL, 0) call. This probably won’t do any
    harm (since any reasonable memcpy() implementation will immediately
    return if (len == 0)), but the standard allows for memcpy() to explode
    if (data == NULL), regardless of the value of len.
    
    In order to be conformant, and to shut up the scan-build static analysis
    warning about it, only do the memcpy() if (len > 0).
---
 stun/stunmessage.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/stun/stunmessage.c b/stun/stunmessage.c
index e9a831c..874d3f1 100644
--- a/stun/stunmessage.c
+++ b/stun/stunmessage.c
@@ -377,7 +377,9 @@ stun_message_append_bytes (StunMessage *msg, StunAttribute type,
   if (ptr == NULL)
     return STUN_MESSAGE_RETURN_NOT_ENOUGH_SPACE;
 
-  memcpy (ptr, data, len);
+  if (len > 0)
+    memcpy (ptr, data, len);
+
   return STUN_MESSAGE_RETURN_SUCCESS;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git



More information about the Pkg-telepathy-commits mailing list