diff options
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/connection.c | 8 | ||||
-rw-r--r-- | src/or/dirserv.c | 2 | ||||
-rw-r--r-- | src/or/rendcommon.c | 1 |
3 files changed, 9 insertions, 2 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index b2412a2a34..c791309d68 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -811,7 +811,13 @@ create_unix_sockaddr(const char *listenaddress, char **readable_address, sockaddr = tor_malloc_zero(sizeof(struct sockaddr_un)); sockaddr->sun_family = AF_UNIX; - strncpy(sockaddr->sun_path, listenaddress, sizeof(sockaddr->sun_path)); + if (strlcpy(sockaddr->sun_path, listenaddress, sizeof(sockaddr->sun_path)) + >= sizeof(sockaddr->sun_path)) { + log_warn(LD_CONFIG, "Unix socket path '%s' is too long to fit.", + escaped(listenaddress)); + tor_free(sockaddr); + return NULL; + } if (readable_address) *readable_address = tor_strdup(listenaddress); diff --git a/src/or/dirserv.c b/src/or/dirserv.c index d114d8654e..7df9a2fcaa 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2415,7 +2415,7 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line) tor_free(line); return -1; } - strncpy(out->node_hex, cp, sizeof(out->node_hex)); + strlcpy(out->node_hex, cp, sizeof(out->node_hex)); got_node_id=1; } } while ((cp = tor_strtok_r(NULL, " \t", &strtok_state))); diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index 3b18bf6078..c5bf88163d 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -1041,6 +1041,7 @@ rend_cache_store(const char *desc, size_t desc_len, int published, log_warn(LD_REND, "Received service descriptor for service ID %s; " "expected descriptor for service ID %s.", query, safe_str(service_id)); + rend_service_descriptor_free(parsed); return -2; } now = time(NULL); |