From 16657041b5ccbb3db000a75d70dab3683dba8055 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Wed, 29 May 2019 14:54:42 +0200 Subject: [PATCH] tools: Don't de-reference the end iterator Reported by Coverity (CID 1401654, 1401671, 1401678, 1401691). --- pdns/dnstcpbench.cc | 4 ++-- pdns/nsec3dig.cc | 2 +- pdns/saxfr.cc | 4 ++-- pdns/sdig.cc | 4 ++-- pdns/toysdig.cc | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pdns/dnstcpbench.cc b/pdns/dnstcpbench.cc index c513e98558..d69b6c6866 100644 --- a/pdns/dnstcpbench.cc +++ b/pdns/dnstcpbench.cc @@ -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); diff --git a/pdns/nsec3dig.cc b/pdns/nsec3dig.cc index ee7430471f..eb6430491f 100644 --- a/pdns/nsec3dig.cc +++ b/pdns/nsec3dig.cc @@ -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"); diff --git a/pdns/saxfr.cc b/pdns/saxfr.cc index a6d4ec84d3..641008582e 100644 --- a/pdns/saxfr.cc +++ b/pdns/saxfr.cc @@ -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; diff --git a/pdns/sdig.cc b/pdns/sdig.cc index 9d0b8d5c83..9d366f865a 100644 --- a/pdns/sdig.cc +++ b/pdns/sdig.cc @@ -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))); diff --git a/pdns/toysdig.cc b/pdns/toysdig.cc index f238f4e24d..82fba8763a 100644 --- a/pdns/toysdig.cc +++ b/pdns/toysdig.cc @@ -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) -- 2.47.2