diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-07-16 13:59:09 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-08-15 12:03:35 -0400 |
commit | 50136b66981ae80c2b139aa441a8472c84bc11e6 (patch) | |
tree | 8f8fc4e7efa60e424c13892495d0839ccf38828e /src | |
parent | 550af7be0ae49f98d6ee7724934de115c80de4a9 (diff) | |
download | tor-50136b66981ae80c2b139aa441a8472c84bc11e6.tar.gz tor-50136b66981ae80c2b139aa441a8472c84bc11e6.zip |
Use memdup_nulterm and check for NULs in handle_cmd_transport
Diffstat (limited to 'src')
-rw-r--r-- | src/or/ext_orport.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/or/ext_orport.c b/src/or/ext_orport.c index 7dfe6248b0..e0980dedac 100644 --- a/src/or/ext_orport.c +++ b/src/or/ext_orport.c @@ -467,9 +467,13 @@ static int connection_ext_or_handle_cmd_transport(or_connection_t *conn, const char *payload, uint16_t len) { - char *transport_str = tor_malloc(len + 1); /* NUL-terminate the string */ - memcpy(transport_str, payload, len); - transport_str[len] = 0; + char *transport_str; + if (memchr(payload, '\0', len)) { + log_fn(LOG_PROTOCOL_WARN, LD_NET, "Unexpected NUL in ExtORPort Transport"); + return -1; + } + + transport_str = tor_memdup_nulterm(payload, len); /* Transport names MUST be C-identifiers. */ if (!string_is_C_identifier(transport_str)) { |