diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-11-23 23:04:10 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-11-23 23:04:10 -0500 |
commit | 3ebe960f3f734322ea3ea471ca6abceb245ca322 (patch) | |
tree | fbc18e8dac6c426fa5fc52a0087c9fcf8bdccea3 /src | |
parent | fbf1c5ee79490577ec0b8c68338ba4f872e993b4 (diff) | |
download | tor-3ebe960f3f734322ea3ea471ca6abceb245ca322.tar tor-3ebe960f3f734322ea3ea471ca6abceb245ca322.tar.gz |
Detect tor_addr_to_str failure in tor_dup_addr.
This avoids a possible strdup of an uninitialized buffer.
Fixes 4529; fix on 0.2.1.3-alpha; reported by troll_un.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/address.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/address.c b/src/common/address.c index 7fc730105..46ccb1fe4 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -945,8 +945,11 @@ char * tor_dup_addr(const tor_addr_t *addr) { char buf[TOR_ADDR_BUF_LEN]; - tor_addr_to_str(buf, addr, sizeof(buf), 0); - return tor_strdup(buf); + if (tor_addr_to_str(buf, addr, sizeof(buf), 0)) { + return tor_strdup(buf); + } else { + return tor_strdup("<unknown address type>"); + } } /** Return a string representing the address <b>addr</b>. This string is |