]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#851,!24-p] Address issue in use of strcpy.
authorMarcin Siodelski <marcin@isc.org>
Thu, 22 Aug 2019 15:48:39 +0000 (17:48 +0200)
committerMarcin Siodelski <marcin@isc.org>
Thu, 22 Aug 2019 15:48:39 +0000 (17:48 +0200)
src/lib/dhcp/tests/iface_mgr_unittest.cc
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/testutils/unix_control_client.cc
src/lib/util/io/socketsession.cc

index 2a63a1a6a2bbef210e7ed2ba3ad49aa02bbb861b..e372c758b9a468f0e4703ff0c8fa4828a8e79b0d 100644 (file)
@@ -2602,7 +2602,7 @@ checkIfAddrs(const Iface & iface, struct ifaddrs *& ifptr) {
 
         struct ifreq ifr;
         memset(& ifr.ifr_name, 0, sizeof ifr.ifr_name);
-        strncpy(ifr.ifr_name, iface.getName().c_str(), sizeof ifr.ifr_name);
+        strncpy(ifr.ifr_name, iface.getName().c_str(), sizeof(ifr.ifr_name) - 1);
 
         int s = -1; // Socket descriptor
 
index e577b4ac3222ff2ec1a7e591a1df9ddf7b2b317c..7963213e79c9f84f8cc64cdca79321b6084039ef 100644 (file)
@@ -370,7 +370,7 @@ public:
             // auth key
             bind_[13].buffer_type = MYSQL_TYPE_STRING;
             std::string auth_key = host->getKey().toText();
-            std::strncpy(auth_key_, auth_key.c_str(), TEXT_AUTH_KEY_LEN);
+            std::strncpy(auth_key_, auth_key.c_str(), TEXT_AUTH_KEY_LEN - 1);
             auth_key_null_ =  auth_key.empty() ? MLM_TRUE : MLM_FALSE;
             bind_[13].buffer = auth_key_;
             bind_[13].buffer_length = auth_key.length();
index 2d180c85f032e1deadb191c5b9bfc3c53e088083..f0f8dfaaab3fd2a53629b8077617c8f7ac88e4b5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -56,7 +56,7 @@ bool UnixControlClient::connectToServer(const std::string& socket_path) {
     memset(&srv_addr, 0, sizeof(srv_addr));
     srv_addr.sun_family = AF_UNIX;
     strncpy(srv_addr.sun_path, socket_path.c_str(),
-            sizeof(srv_addr.sun_path));
+            sizeof(srv_addr.sun_path) - 1);
     socklen_t len = sizeof(srv_addr);
 
     // Connect to the specified UNIX socket
index 5b3a72bd62223974fb7b1f7b472fb82e076c12f2..c19ab450f1e0d4209243eba8fe2e957c5ad43200 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -103,7 +103,7 @@ SocketSessionForwarder::SocketSessionForwarder(const std::string& unix_file) :
     // paranoid about making it 100% sure even if the check has a bug (with
     // triggering the assertion in the worse case)
     strncpy(impl.sock_un_.sun_path, unix_file.c_str(),
-            sizeof(impl.sock_un_.sun_path));
+            sizeof(impl.sock_un_.sun_path) - 1);
     assert(impl.sock_un_.sun_path[sizeof(impl.sock_un_.sun_path) - 1] == '\0');
     impl.sock_un_len_ = offsetof(struct sockaddr_un, sun_path) +
         unix_file.length();