From cefe0a1959bb62fb36170dc3ff8c15b9971bb822 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 20 Feb 2008 16:57:39 +0000 Subject: r18255@catbus: nickm | 2008-02-20 11:44:55 -0500 Add asserts and refactor some comparisons in order to fix some veracode-identified issues. Note a bug in buffers.c svn:r13618 --- src/or/dirvote.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/or/dirvote.c') diff --git a/src/or/dirvote.c b/src/or/dirvote.c index e2ff5723ac..1455418a88 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -1787,16 +1787,17 @@ dirvote_add_signatures_to_pending_consensus( char *new_detached = networkstatus_get_detached_signatures(pending_consensus); const char *src; - char *dst; + char *dst, *dst_end; size_t new_consensus_len = strlen(pending_consensus_body) + strlen(new_detached) + 1; pending_consensus_body = tor_realloc(pending_consensus_body, new_consensus_len); + dst_end = pending_consensus_body + new_consensus_len; dst = strstr(pending_consensus_body, "directory-signature "); tor_assert(dst); src = strstr(new_detached, "directory-signature "); tor_assert(src); - strlcpy(dst, src, new_consensus_len - (dst-pending_consensus_body)); + strlcpy(dst, src, dst_end-dst); /* We remove this block once it has failed to crash for a while. But * unless it shows up in profiles, we're probably better leaving it in, -- cgit v1.2.3-54-g00ecf