2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 22:15:23 +00:00

[#851,!24-p] Address issue in use of strcpy.

This commit is contained in:
Marcin Siodelski
2019-08-22 17:48:39 +02:00
parent 10fe55ce89
commit 8e9b4b312b
4 changed files with 6 additions and 6 deletions

View 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

View 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();

View 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

View 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();