Skip to content

Commit

Permalink
fix few unitialized data.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored and dormando committed Mar 8, 2023
1 parent 0af22a3 commit a9f1785
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ static void _logger_log_conn_event(logentry *e, const entry_details *d, const vo
static int _logger_util_addr_endpoint(struct sockaddr_in6 *addr, char *rip,
size_t riplen, unsigned short *rport) {
memset(rip, 0, riplen);
*rport = 0;

switch (addr->sin6_family) {
case AF_INET:
Expand All @@ -177,7 +178,6 @@ static int _logger_util_addr_endpoint(struct sockaddr_in6 *addr, char *rip,
case AF_UNSPEC:
case AF_UNIX:
strncpy(rip, "unix", strlen("unix") + 1);
*rport = 0;
break;
#endif // #ifndef DISABLE_UNIX_SOCKET
}
Expand Down
2 changes: 2 additions & 0 deletions memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -2124,6 +2124,7 @@ static void conn_to_str(const conn *c, char *addr, char *svr_addr) {
if (c->state == conn_listening ||
(IS_UDP(c->transport) &&
c->state == conn_read)) {
memset(&local_addr, 0, sizeof(local_addr));
socklen_t local_addr_len = sizeof(local_addr);

if (getsockname(c->sfd,
Expand All @@ -2137,6 +2138,7 @@ static void conn_to_str(const conn *c, char *addr, char *svr_addr) {
if (c->state != conn_listening && !(IS_UDP(c->transport) &&
c->state == conn_read)) {
struct sockaddr_storage svr_sock_addr;
memset(&svr_sock_addr, 0, sizeof(svr_sock_addr));
socklen_t svr_addr_len = sizeof(svr_sock_addr);
getsockname(c->sfd, (struct sockaddr *)&svr_sock_addr, &svr_addr_len);
get_conn_text(c, svr_sock_addr.ss_family, svr_addr, (struct sockaddr *)&svr_sock_addr);
Expand Down

0 comments on commit a9f1785

Please sign in to comment.