]> granicus.if.org Git - pdns/commitdiff
Fix a GCC warning about strncpy()
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 4 Jun 2018 09:49:50 +0000 (11:49 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 4 Jun 2018 09:49:50 +0000 (11:49 +0200)
We always NULL-terminate the string anyway, but let's make the
compiler happy.

pdns/rec_channel.cc

index 3c0fb6d87166401024501f26f3d9823b89727b7e..2bbb54c1a3d50fbbe2b7bb1ea9d65c9f548bbf29 100644 (file)
@@ -115,7 +115,7 @@ void RecursorControlChannel::send(const std::string& msg, const std::string* rem
     memset(&remoteaddr, 0, sizeof(remoteaddr));
   
     remoteaddr.sun_family=AF_UNIX;
-    strncpy(remoteaddr.sun_path, remote->c_str(), sizeof(remoteaddr.sun_path));
+    strncpy(remoteaddr.sun_path, remote->c_str(), sizeof(remoteaddr.sun_path)-1);
     remoteaddr.sun_path[sizeof(remoteaddr.sun_path)-1] = '\0';
 
     if(::sendto(d_fd, msg.c_str(), msg.length(), 0, (struct sockaddr*) &remoteaddr, sizeof(remoteaddr) ) < 0)