BIND 10 trac1452, updated. 5050c9607584178e27d9caf196c25df01b3cd651 [1452] added a clarification comment on assert+strncpy; use offsetof instead of hardcoding the corresponding value.
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Dec 19 18:15:42 UTC 2011
The branch, trac1452 has been updated
via 5050c9607584178e27d9caf196c25df01b3cd651 (commit)
from 43df0d5564a5363deaeb8e1a3b76eff3426adf4c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5050c9607584178e27d9caf196c25df01b3cd651
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Mon Dec 19 10:14:53 2011 -0800
[1452] added a clarification comment on assert+strncpy; use offsetof instead
of hardcoding the corresponding value.
-----------------------------------------------------------------------
Summary of changes:
src/lib/util/io/socketsession.cc | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/util/io/socketsession.cc b/src/lib/util/io/socketsession.cc
index 2199eb9..4bf5100 100644
--- a/src/lib/util/io/socketsession.cc
+++ b/src/lib/util/io/socketsession.cc
@@ -26,6 +26,7 @@
#include <cerrno>
#include <csignal>
+#include <cstddef>
#include <cstring>
#include <cassert>
@@ -102,10 +103,14 @@ SocketSessionForwarder::SocketSessionForwarder(const std::string& unix_file) :
unix_file);
}
impl.sock_un_.sun_family = AF_UNIX;
+ // 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)
strncpy(impl.sock_un_.sun_path, unix_file.c_str(),
sizeof(impl.sock_un_.sun_path));
assert(impl.sock_un_.sun_path[sizeof(impl.sock_un_.sun_path) - 1] == '\0');
- impl.sock_un_len_ = 2 + unix_file.length();
+ impl.sock_un_len_ = offsetof(struct sockaddr_un, sun_path) +
+ unix_file.length();
#ifdef HAVE_SA_LEN
impl.sock_un_.sun_len = impl.sock_un_len_;
#endif
More information about the bind10-changes
mailing list