Commit a877be12 authored by Marcin Siodelski's avatar Marcin Siodelski

[#851,!24-p] Make sure that string is null terminated after strncpy.

parent 8e9b4b31
......@@ -119,6 +119,7 @@ public:
memset(user_context_, 0, sizeof(user_context_));
memset(dhcp4_server_hostname_, 0, sizeof(dhcp4_server_hostname_));
memset(dhcp4_boot_file_name_, 0, sizeof(dhcp4_boot_file_name_));
memset(auth_key_, 0, sizeof(auth_key_));
// Set the column names for use by this class. This only comprises
// names used by the MySqlHostExchange class. Derived classes will
......
......@@ -102,6 +102,7 @@ SocketSessionForwarder::SocketSessionForwarder(const std::string& unix_file) :
// the copy should be safe due to the above check, but we'd be rather
// paranoid about making it 100% sure even if the check has a bug (with
// triggering the assertion in the worse case)
memset(&impl.sock_un_.sun_path, 0, sizeof(impl.sock_un_.sun_path));
strncpy(impl.sock_un_.sun_path, unix_file.c_str(),
sizeof(impl.sock_un_.sun_path) - 1);
assert(impl.sock_un_.sun_path[sizeof(impl.sock_un_.sun_path) - 1] == '\0');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment