mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Allow socks4_server_reply version to be 0 (for tor-resolve)
This commit is contained in:
parent
83af6d6149
commit
d49baa77b5
@ -1694,7 +1694,6 @@ socks4_server_reply_new(void)
|
||||
socks4_server_reply_t *val = trunnel_calloc(1, sizeof(socks4_server_reply_t));
|
||||
if (NULL == val)
|
||||
return NULL;
|
||||
val->version = 4;
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -1724,7 +1723,7 @@ socks4_server_reply_get_version(const socks4_server_reply_t *inp)
|
||||
int
|
||||
socks4_server_reply_set_version(socks4_server_reply_t *inp, uint8_t val)
|
||||
{
|
||||
if (! ((val == 4))) {
|
||||
if (! ((val == 0 || val == 4))) {
|
||||
TRUNNEL_SET_ERROR_CODE(inp);
|
||||
return -1;
|
||||
}
|
||||
@ -1771,7 +1770,7 @@ socks4_server_reply_check(const socks4_server_reply_t *obj)
|
||||
return "Object was NULL";
|
||||
if (obj->trunnel_error_code_)
|
||||
return "A set function failed on this object";
|
||||
if (! (obj->version == 4))
|
||||
if (! (obj->version == 0 || obj->version == 4))
|
||||
return "Integer out of bounds";
|
||||
return NULL;
|
||||
}
|
||||
@ -1785,7 +1784,7 @@ socks4_server_reply_encoded_len(const socks4_server_reply_t *obj)
|
||||
return -1;
|
||||
|
||||
|
||||
/* Length of u8 version IN [4] */
|
||||
/* Length of u8 version IN [0, 4] */
|
||||
result += 1;
|
||||
|
||||
/* Length of u8 status */
|
||||
@ -1823,7 +1822,7 @@ socks4_server_reply_encode(uint8_t *output, const size_t avail, const socks4_ser
|
||||
trunnel_assert(encoded_len >= 0);
|
||||
#endif
|
||||
|
||||
/* Encode u8 version IN [4] */
|
||||
/* Encode u8 version IN [0, 4] */
|
||||
trunnel_assert(written <= avail);
|
||||
if (avail - written < 1)
|
||||
goto truncated;
|
||||
@ -1886,11 +1885,11 @@ socks4_server_reply_parse_into(socks4_server_reply_t *obj, const uint8_t *input,
|
||||
ssize_t result = 0;
|
||||
(void)result;
|
||||
|
||||
/* Parse u8 version IN [4] */
|
||||
/* Parse u8 version IN [0, 4] */
|
||||
CHECK_REMAINING(1, truncated);
|
||||
obj->version = (trunnel_get_uint8(ptr));
|
||||
remaining -= 1; ptr += 1;
|
||||
if (! (obj->version == 4))
|
||||
if (! (obj->version == 0 || obj->version == 4))
|
||||
goto fail;
|
||||
|
||||
/* Parse u8 status */
|
||||
|
@ -86,7 +86,7 @@ struct socks4_client_request {
|
||||
}
|
||||
|
||||
struct socks4_server_reply {
|
||||
u8 version IN [4];
|
||||
u8 version IN [0,4];
|
||||
u8 status;
|
||||
u16 port;
|
||||
u32 addr;
|
||||
|
Loading…
Reference in New Issue
Block a user