aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-04-25 01:24:39 -0400
committerNick Mathewson <nickm@torproject.org>2014-04-25 01:24:39 -0400
commitd3c05a79f0b3e688e43edfffe9886664777517f7 (patch)
treecaf18aa657f83c5bf224bd2750dc5e81d2000e3d /src/common
parent12b1d64b0378450fb8c69dfe81fde2d1cd1b36b1 (diff)
parent5470795b834a788ec482f22091d58b27a1999a2d (diff)
downloadtor-d3c05a79f0b3e688e43edfffe9886664777517f7.tar
tor-d3c05a79f0b3e688e43edfffe9886664777517f7.tar.gz
Merge branch 'scanbuild_fixes'
Diffstat (limited to 'src/common')
-rw-r--r--src/common/address.c4
-rw-r--r--src/common/compat.c4
-rw-r--r--src/common/memarea.c7
3 files changed, 8 insertions, 7 deletions
diff --git a/src/common/address.c b/src/common/address.c
index e5930dedc..2825b123d 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -236,7 +236,9 @@ tor_addr_lookup(const char *name, uint16_t family, tor_addr_t *addr)
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
err = sandbox_getaddrinfo(name, NULL, &hints, &res);
- if (!err) {
+ /* The check for 'res' here shouldn't be necessary, but it makes static
+ * analysis tools happy. */
+ if (!err && res) {
best = NULL;
for (res_p = res; res_p; res_p = res_p->ai_next) {
if (family == AF_UNSPEC) {
diff --git a/src/common/compat.c b/src/common/compat.c
index 9b96a35fe..1ba264a0c 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -2198,8 +2198,10 @@ tor_inet_pton(int af, const char *src, void *dst)
else {
unsigned byte1,byte2,byte3,byte4;
char more;
- for (eow = dot-1; eow >= src && TOR_ISDIGIT(*eow); --eow)
+ for (eow = dot-1; eow > src && TOR_ISDIGIT(*eow); --eow)
;
+ if (*eow != ':')
+ return 0;
++eow;
/* We use "scanf" because some platform inet_aton()s are too lax
diff --git a/src/common/memarea.c b/src/common/memarea.c
index e2d07fca9..bcaea0949 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -291,14 +291,11 @@ memarea_strdup(memarea_t *area, const char *s)
char *
memarea_strndup(memarea_t *area, const char *s, size_t n)
{
- size_t ln;
+ size_t ln = 0;
char *result;
- const char *cp, *end = s+n;
tor_assert(n < SIZE_T_CEILING);
- for (cp = s; cp < end && *cp; ++cp)
+ for (ln = 0; ln < n && s[ln]; ++ln)
;
- /* cp now points to s+n, or to the 0 in the string. */
- ln = cp-s;
result = memarea_alloc(area, ln+1);
memcpy(result, s, ln);
result[ln]='\0';