moonchen commented on code in PR #13356:
URL: https://github.com/apache/trafficserver/pull/13356#discussion_r3575022537


##########
include/tscore/ink_inet.h:
##########
@@ -1610,9 +1611,9 @@ struct UnAddr {
 
   UnAddr() { _path[0] = 0; }
 
-  UnAddr(self const &addr) { strncpy(_path, addr._path, TS_UNIX_SIZE); }
-  explicit UnAddr(const char *path) { strncpy(_path, path, TS_UNIX_SIZE - 1); }
-  explicit UnAddr(const std::string &path) { strncpy(_path, path.c_str(), 
TS_UNIX_SIZE); }
+  UnAddr(self const &addr) { ink_strlcpy(_path, addr._path, TS_UNIX_SIZE); }
+  explicit UnAddr(const char *path) { ink_strlcpy(_path, path, TS_UNIX_SIZE); }
+  explicit UnAddr(const std::string &path) { ink_strlcpy(_path, path.c_str(), 
TS_UNIX_SIZE); }
 
   explicit UnAddr(sockaddr const *addr) { this->assign(addr); }

Review Comment:
   Done in b42ce06f59. `_path` now has a default member initializer (`char 
_path[TS_UNIX_SIZE]{}`), so a constructor whose `assign()` receives a null 
address yields a valid empty string instead of uninitialized bytes, and the 
copy paths no longer read uninitialized memory. Also guarded the `IpEndpoint 
const *` constructor against a null pointer. Added a null-address regression 
test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to