]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
tools: Don't de-reference the end iterator
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 29 May 2019 12:54:42 +0000 (14:54 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 29 May 2019 12:54:42 +0000 (14:54 +0200)
Reported by Coverity (CID 1401654140167114016781401691).

pdns/dnstcpbench.cc
pdns/nsec3dig.cc
pdns/saxfr.cc
pdns/sdig.cc
pdns/toysdig.cc

index c513e985580d9f853bf516b2b35da9557dac678c..d69b6c6866c030de969fb679203031ca03d7598c 100644 (file)
@@ -83,7 +83,7 @@ try
   if(!g_onlyTCP) {
     Socket udpsock(g_dest.sin4.sin_family, SOCK_DGRAM);
     
-    udpsock.sendTo(string((char*)&*packet.begin(), (char*)&*packet.end()), g_dest);
+    udpsock.sendTo(string(packet.begin(), packet.end()), g_dest);
     ComboAddress origin;
     res = waitForData(udpsock.getHandle(), 0, 1000 * g_timeoutMsec);
     if(res < 0)
@@ -116,7 +116,7 @@ try
   sock.connect(g_dest);
   uint16_t len = htons(packet.size());
   string tcppacket((char*)& len, 2);
-  tcppacket.append((char*)&*packet.begin(), (char*)&*packet.end());
+  tcppacket.append(packet.begin(), packet.end());
 
   sock.writen(tcppacket);
 
index ee7430471f9aa0b5f3c14e5b25e4b81d083278d8..eb6430491f3bc7738800f1b468b3b1258425b52a 100644 (file)
@@ -136,7 +136,7 @@ try
   if(sock.write((char *) &len, 2) != 2)
     throw PDNSException("tcp write failed");
 
-  sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+  sock.writen(string(packet.begin(), packet.end()));
   
   if(sock.read((char *) &len, 2) != 2)
     throw PDNSException("tcp read failed");
index a6d4ec84d34e92dfb156b2096866b09c98a4a877..641008582ef363bfb33d43daba9d06ca79e52592 100644 (file)
@@ -123,7 +123,7 @@ try
       len = htons(packet.size());
       if(sock.write((char *) &len, 2) != 2)
         throw PDNSException("tcp write failed");
-      sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+      sock.writen(string((char*)&packet[0], packet.size()));
       if(sock.read((char *) &len, 2) != 2)
         throw PDNSException("tcp read failed");
 
@@ -177,7 +177,7 @@ try
   if(sock.write((char *) &len, 2) != 2)
     throw PDNSException("tcp write failed");
 
-  sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+  sock.writen(string(packet.begin(), packet.end()));
 
   bool isNSEC3 = false;
   int soacount=0;
index 9d0b8d5c83b9ff818f153dbfae8087575a1c6ed9..9d366f865a44852befc3664aafcb3ab0f8f12d2e 100644 (file)
@@ -159,7 +159,7 @@ try
     if(sock.write((char *) &len, 2) != 2)
       throw PDNSException("tcp write failed");
 
-    sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+    sock.writen(string(packet.begin(), packet.end()));
     
     if(sock.read((char *) &len, 2) != 2)
       throw PDNSException("tcp read failed");
@@ -181,7 +181,7 @@ try
   else //udp
   {
     Socket sock(dest.sin4.sin_family, SOCK_DGRAM);
-    sock.sendTo(string((char*)&*packet.begin(), (char*)&*packet.end()), dest);
+    sock.sendTo(string(packet.begin(), packet.end()), dest);
     int result=waitForData(sock.getHandle(), 10);
     if(result < 0) 
       throw std::runtime_error("Error waiting for data: "+string(strerror(errno)));
index f238f4e24d3d490e591ca3b3bbc02b9ca10922c7..82fba8763afbac36fee6541af81da942b299b926 100644 (file)
@@ -47,7 +47,7 @@ public:
     if(d_rsock.write((char *) &len, 2) != 2)
       throw PDNSException("tcp write failed");
 
-    d_rsock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
+    d_rsock.writen(string(packet.begin(), packet.end()));
     
     int bread=d_rsock.read((char *) &len, 2);
     if( bread <0)