mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Mark some tests in parse_socks.c as unreachable (BUG, LCOV)
These tests aren't reachable, given their actual arguments. I'm going to mark them as BUG(), and as unreachable with LCOV.
This commit is contained in:
parent
5427365907
commit
14124f82df
@ -340,13 +340,16 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
|
||||
|
||||
tor_addr_to_str(tmpbuf, &destaddr, sizeof(tmpbuf), 1);
|
||||
|
||||
if (strlen(tmpbuf)+1 > MAX_SOCKS_ADDR_LEN) {
|
||||
if (BUG(strlen(tmpbuf)+1 > MAX_SOCKS_ADDR_LEN)) {
|
||||
/* LCOV_EXCL_START -- This branch is unreachable, given the
|
||||
* size of tmpbuf and the actual value of MAX_SOCKS_ADDR_LEN */
|
||||
socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
|
||||
log_warn(LD_APP,
|
||||
"socks5 IP takes %d bytes, which doesn't fit in %d. "
|
||||
"Rejecting.",
|
||||
(int)strlen(tmpbuf)+1,(int)MAX_SOCKS_ADDR_LEN);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
strlcpy(req->address,tmpbuf,sizeof(req->address));
|
||||
req->port = ntohs(get_uint16(data+4+addrlen));
|
||||
@ -375,12 +378,15 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
|
||||
*want_length_out = 7+len;
|
||||
return 0; /* not yet */
|
||||
}
|
||||
if (len+1 > MAX_SOCKS_ADDR_LEN) {
|
||||
if (BUG(len+1 > MAX_SOCKS_ADDR_LEN)) {
|
||||
/* LCOV_EXCL_START -- unreachable, since len is at most 255,
|
||||
* and MAX_SOCKS_ADDR_LEN is 256. */
|
||||
socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
|
||||
log_warn(LD_APP,
|
||||
"socks5 hostname is %d bytes, which doesn't fit in "
|
||||
"%d. Rejecting.", len+1,MAX_SOCKS_ADDR_LEN);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
memcpy(req->address,data+5,len);
|
||||
req->address[len] = 0;
|
||||
@ -443,10 +449,13 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
|
||||
log_debug(LD_APP,"socks4: destip not in form 0.0.0.x.");
|
||||
in.s_addr = htonl(destip);
|
||||
tor_inet_ntoa(&in,tmpbuf,sizeof(tmpbuf));
|
||||
if (strlen(tmpbuf)+1 > MAX_SOCKS_ADDR_LEN) {
|
||||
if (BUG(strlen(tmpbuf)+1 > MAX_SOCKS_ADDR_LEN)) {
|
||||
/* LCOV_EXCL_START -- This branch is unreachable, given the
|
||||
* size of tmpbuf and the actual value of MAX_SOCKS_ADDR_LEN */
|
||||
log_debug(LD_APP,"socks4 addr (%d bytes) too long. Rejecting.",
|
||||
(int)strlen(tmpbuf));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
log_debug(LD_APP,
|
||||
"socks4: successfully read destip (%s)",
|
||||
|
Loading…
Reference in New Issue
Block a user