diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-08-04 12:17:53 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-04 12:17:53 -0400 |
commit | 3b646bf887f95c7f26ca05fb7fb3af10806b1328 (patch) | |
tree | ce2c13e26ed67f30ab2494ccf25780db071f845c | |
parent | 32b4fd5be9574a1f17947416889be9067db483b7 (diff) | |
download | tor-3b646bf887f95c7f26ca05fb7fb3af10806b1328.tar.gz tor-3b646bf887f95c7f26ca05fb7fb3af10806b1328.zip |
Fix ntohs() that should have been htons()
Fixes bug 23106; bugfix on 0.2.4.8-alpha.
Fortunately, we only support big-endian and little-endian platforms,
and on both of those, hton*() and ntoh*() behave the same. And if
we did start to support middle endian systems (haha, no), most of
_those_ have hton*(x) == ntoh*(x) too.
-rw-r--r-- | changes/bug23106 | 5 | ||||
-rw-r--r-- | src/or/onion.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/changes/bug23106 b/changes/bug23106 new file mode 100644 index 0000000000..d4ced15f82 --- /dev/null +++ b/changes/bug23106 @@ -0,0 +1,5 @@ + o Minor bugfixes (code correctness): + - Call htons() in extend_cell_format() for encoding a 16-bit + value. Previously we used ntohs(), which happens to behave the + same on all the platforms we support, but which isn't really + correct. Fixes bug 23106; bugfix on 0.2.4.8-alpha. diff --git a/src/or/onion.c b/src/or/onion.c index a98b97cb1d..7e1e89df1b 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -1219,7 +1219,7 @@ extend_cell_format(uint8_t *command_out, uint16_t *len_out, *command_out = RELAY_COMMAND_EXTEND; *len_out = 6 + TAP_ONIONSKIN_CHALLENGE_LEN + DIGEST_LEN; set_uint32(p, tor_addr_to_ipv4n(&cell_in->orport_ipv4.addr)); - set_uint16(p+4, ntohs(cell_in->orport_ipv4.port)); + set_uint16(p+4, htons(cell_in->orport_ipv4.port)); if (cell_in->create_cell.handshake_type == ONION_HANDSHAKE_TYPE_NTOR) { memcpy(p+6, NTOR_CREATE_MAGIC, 16); memcpy(p+22, cell_in->create_cell.onionskin, NTOR_ONIONSKIN_LEN); |