]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Hopefully prevent a CodeQL warning in the netlink code
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 3 May 2022 10:15:57 +0000 (12:15 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 3 May 2022 10:15:57 +0000 (12:15 +0200)
pdns/misc.cc

index d0837585b9ee6d33a8e210bd9abd05d75cc7a44c..9af6543b4259646a700d8160a485e6f0adb8a3d7 100644 (file)
@@ -1204,7 +1204,7 @@ int getMACAddress(const ComboAddress& ca, char* dest, size_t destLen)
       }
 
       auto nd = reinterpret_cast<struct ndmsg*>(NLMSG_DATA(nlmsgheader));
-      auto rtatp = reinterpret_cast<struct rtattr*>(((char*)(nd)) + NLMSG_ALIGN(sizeof(struct ndmsg)));
+      auto rtatp = reinterpret_cast<struct rtattr*>(reinterpret_cast<char*>(nd) + NLMSG_ALIGN(sizeof(struct ndmsg)));
       int rtattrlen = nlmsgheader->nlmsg_len - NLMSG_LENGTH(sizeof(struct ndmsg));
 
       if (nd->ndm_family != ca.sin4.sin_family) {
@@ -1231,7 +1231,7 @@ int getMACAddress(const ComboAddress& ca, char* dest, size_t destLen)
             if ((rtatp->rta_len - sizeof(struct rtattr)) != destLen) {
               return EINVAL;
             }
-            memcpy(dest, (rtatp+1), destLen);
+            memcpy(dest, reinterpret_cast<const char*>(rtatp) + sizeof(struct rtattr), destLen);
             foundMAC = true;
             done = true;
             break;