]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Not calling memcpy with n=0.
authorMaria Matejka <mq@ucw.cz>
Wed, 14 Aug 2019 08:28:23 +0000 (10:28 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 28 Apr 2020 14:21:06 +0000 (16:21 +0200)
lib/string.h
proto/bgp/bgp.h

index d6ae5ef7587fc8546239b53ec1c1a33d0c3c1cd1..0f650178de6697d0fc2e4ea403ff260d68edff9e 100644 (file)
@@ -72,6 +72,15 @@ bstrcmp(const char *s1, const char *s2)
     return !s2 - !s1;
 }
 
+static inline void *
+bmemcpy(void *dest, const void *src, size_t n)
+{
+  if (n)
+    return memcpy(dest, src, n);
+  else
+    return dest;
+}
+
 #define ROUTER_ID_64_LENGTH 23
 
 #endif
index dc63e13eac7fdb927042f594467127e149768287..0529c45aaaf7478544bd23af8d95aed5d571dc69 100644 (file)
@@ -552,7 +552,7 @@ static inline void
 bgp_set_attr_data(ea_list **to, struct linpool *pool, uint code, uint flags, void *data, uint len)
 {
   struct adata *a = lp_alloc_adata(pool, len);
-  memcpy(a->data, data, len);
+  bmemcpy(a->data, data, len);
   bgp_set_attr(to, pool, code, flags, (uintptr_t) a);
 }