]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/msg_types: make set_sockaddr() a bit more robust
authorSage Weil <sage@redhat.com>
Tue, 15 Jan 2019 02:48:36 +0000 (20:48 -0600)
committerSage Weil <sage@redhat.com>
Tue, 15 Jan 2019 02:48:36 +0000 (20:48 -0600)
We should keep the unused parts of u zeroed.

Signed-off-by: Sage Weil <sage@redhat.com>
src/msg/msg_types.h

index 1049ad540a0c1fe55bbcbd031217fbcd19b77606..63d64ce8c6023a0457ab9b3b149033d81a27ea96 100644 (file)
@@ -313,9 +313,13 @@ struct entity_addr_t {
   {
     switch (sa->sa_family) {
     case AF_INET:
+      // pre-zero, since we're only copying a portion of the source
+      memset(&u, 0, sizeof(u));
       memcpy(&u.sin, sa, sizeof(u.sin));
       break;
     case AF_INET6:
+      // pre-zero, since we're only copying a portion of the source
+      memset(&u, 0, sizeof(u));
       memcpy(&u.sin6, sa, sizeof(u.sin6));
       break;
     default: