Fix type in socks5.trunnel

This commit is contained in:
rl1987 2018-05-16 14:47:46 +02:00 committed by Nick Mathewson
parent 853d9b869d
commit 75106a26b4
3 changed files with 50 additions and 50 deletions

View File

@ -2838,10 +2838,10 @@ socks5_server_method_parse(socks5_server_method_t **output, const uint8_t *input
} }
return result; return result;
} }
socks5_server_userpath_auth_t * socks5_server_userpass_auth_t *
socks5_server_userpath_auth_new(void) socks5_server_userpass_auth_new(void)
{ {
socks5_server_userpath_auth_t *val = trunnel_calloc(1, sizeof(socks5_server_userpath_auth_t)); socks5_server_userpass_auth_t *val = trunnel_calloc(1, sizeof(socks5_server_userpass_auth_t));
if (NULL == val) if (NULL == val)
return NULL; return NULL;
val->version = 1; val->version = 1;
@ -2851,28 +2851,28 @@ socks5_server_userpath_auth_new(void)
/** Release all storage held inside 'obj', but do not free 'obj'. /** Release all storage held inside 'obj', but do not free 'obj'.
*/ */
static void static void
socks5_server_userpath_auth_clear(socks5_server_userpath_auth_t *obj) socks5_server_userpass_auth_clear(socks5_server_userpass_auth_t *obj)
{ {
(void) obj; (void) obj;
} }
void void
socks5_server_userpath_auth_free(socks5_server_userpath_auth_t *obj) socks5_server_userpass_auth_free(socks5_server_userpass_auth_t *obj)
{ {
if (obj == NULL) if (obj == NULL)
return; return;
socks5_server_userpath_auth_clear(obj); socks5_server_userpass_auth_clear(obj);
trunnel_memwipe(obj, sizeof(socks5_server_userpath_auth_t)); trunnel_memwipe(obj, sizeof(socks5_server_userpass_auth_t));
trunnel_free_(obj); trunnel_free_(obj);
} }
uint8_t uint8_t
socks5_server_userpath_auth_get_version(const socks5_server_userpath_auth_t *inp) socks5_server_userpass_auth_get_version(const socks5_server_userpass_auth_t *inp)
{ {
return inp->version; return inp->version;
} }
int int
socks5_server_userpath_auth_set_version(socks5_server_userpath_auth_t *inp, uint8_t val) socks5_server_userpass_auth_set_version(socks5_server_userpass_auth_t *inp, uint8_t val)
{ {
if (! ((val == 1))) { if (! ((val == 1))) {
TRUNNEL_SET_ERROR_CODE(inp); TRUNNEL_SET_ERROR_CODE(inp);
@ -2882,18 +2882,18 @@ socks5_server_userpath_auth_set_version(socks5_server_userpath_auth_t *inp, uint
return 0; return 0;
} }
uint8_t uint8_t
socks5_server_userpath_auth_get_status(const socks5_server_userpath_auth_t *inp) socks5_server_userpass_auth_get_status(const socks5_server_userpass_auth_t *inp)
{ {
return inp->status; return inp->status;
} }
int int
socks5_server_userpath_auth_set_status(socks5_server_userpath_auth_t *inp, uint8_t val) socks5_server_userpass_auth_set_status(socks5_server_userpass_auth_t *inp, uint8_t val)
{ {
inp->status = val; inp->status = val;
return 0; return 0;
} }
const char * const char *
socks5_server_userpath_auth_check(const socks5_server_userpath_auth_t *obj) socks5_server_userpass_auth_check(const socks5_server_userpass_auth_t *obj)
{ {
if (obj == NULL) if (obj == NULL)
return "Object was NULL"; return "Object was NULL";
@ -2905,11 +2905,11 @@ socks5_server_userpath_auth_check(const socks5_server_userpath_auth_t *obj)
} }
ssize_t ssize_t
socks5_server_userpath_auth_encoded_len(const socks5_server_userpath_auth_t *obj) socks5_server_userpass_auth_encoded_len(const socks5_server_userpass_auth_t *obj)
{ {
ssize_t result = 0; ssize_t result = 0;
if (NULL != socks5_server_userpath_auth_check(obj)) if (NULL != socks5_server_userpass_auth_check(obj))
return -1; return -1;
@ -2921,24 +2921,24 @@ socks5_server_userpath_auth_encoded_len(const socks5_server_userpath_auth_t *obj
return result; return result;
} }
int int
socks5_server_userpath_auth_clear_errors(socks5_server_userpath_auth_t *obj) socks5_server_userpass_auth_clear_errors(socks5_server_userpass_auth_t *obj)
{ {
int r = obj->trunnel_error_code_; int r = obj->trunnel_error_code_;
obj->trunnel_error_code_ = 0; obj->trunnel_error_code_ = 0;
return r; return r;
} }
ssize_t ssize_t
socks5_server_userpath_auth_encode(uint8_t *output, const size_t avail, const socks5_server_userpath_auth_t *obj) socks5_server_userpass_auth_encode(uint8_t *output, const size_t avail, const socks5_server_userpass_auth_t *obj)
{ {
ssize_t result = 0; ssize_t result = 0;
size_t written = 0; size_t written = 0;
uint8_t *ptr = output; uint8_t *ptr = output;
const char *msg; const char *msg;
#ifdef TRUNNEL_CHECK_ENCODED_LEN #ifdef TRUNNEL_CHECK_ENCODED_LEN
const ssize_t encoded_len = socks5_server_userpath_auth_encoded_len(obj); const ssize_t encoded_len = socks5_server_userpass_auth_encoded_len(obj);
#endif #endif
if (NULL != (msg = socks5_server_userpath_auth_check(obj))) if (NULL != (msg = socks5_server_userpass_auth_check(obj)))
goto check_failed; goto check_failed;
#ifdef TRUNNEL_CHECK_ENCODED_LEN #ifdef TRUNNEL_CHECK_ENCODED_LEN
@ -2983,11 +2983,11 @@ socks5_server_userpath_auth_encode(uint8_t *output, const size_t avail, const so
return result; return result;
} }
/** As socks5_server_userpath_auth_parse(), but do not allocate the /** As socks5_server_userpass_auth_parse(), but do not allocate the
* output object. * output object.
*/ */
static ssize_t static ssize_t
socks5_server_userpath_auth_parse_into(socks5_server_userpath_auth_t *obj, const uint8_t *input, const size_t len_in) socks5_server_userpass_auth_parse_into(socks5_server_userpass_auth_t *obj, const uint8_t *input, const size_t len_in)
{ {
const uint8_t *ptr = input; const uint8_t *ptr = input;
size_t remaining = len_in; size_t remaining = len_in;
@ -3016,15 +3016,15 @@ socks5_server_userpath_auth_parse_into(socks5_server_userpath_auth_t *obj, const
} }
ssize_t ssize_t
socks5_server_userpath_auth_parse(socks5_server_userpath_auth_t **output, const uint8_t *input, const size_t len_in) socks5_server_userpass_auth_parse(socks5_server_userpass_auth_t **output, const uint8_t *input, const size_t len_in)
{ {
ssize_t result; ssize_t result;
*output = socks5_server_userpath_auth_new(); *output = socks5_server_userpass_auth_new();
if (NULL == *output) if (NULL == *output)
return -1; return -1;
result = socks5_server_userpath_auth_parse_into(*output, input, len_in); result = socks5_server_userpass_auth_parse_into(*output, input, len_in);
if (result < 0) { if (result < 0) {
socks5_server_userpath_auth_free(*output); socks5_server_userpass_auth_free(*output);
*output = NULL; *output = NULL;
} }
return result; return result;

View File

@ -74,14 +74,14 @@ struct socks5_server_method_st {
}; };
#endif #endif
typedef struct socks5_server_method_st socks5_server_method_t; typedef struct socks5_server_method_st socks5_server_method_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_USERPATH_AUTH) #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_USERPASS_AUTH)
struct socks5_server_userpath_auth_st { struct socks5_server_userpass_auth_st {
uint8_t version; uint8_t version;
uint8_t status; uint8_t status;
uint8_t trunnel_error_code_; uint8_t trunnel_error_code_;
}; };
#endif #endif
typedef struct socks5_server_userpath_auth_st socks5_server_userpath_auth_t; typedef struct socks5_server_userpass_auth_st socks5_server_userpass_auth_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_SOCKSAUTH_KEYVAL) #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_SOCKSAUTH_KEYVAL)
struct tor_socksauth_keyval_st { struct tor_socksauth_keyval_st {
uint16_t keylen; uint16_t keylen;
@ -697,62 +697,62 @@ uint8_t socks5_server_method_get_method(const socks5_server_method_t *inp);
* code on 'inp' on failure. * code on 'inp' on failure.
*/ */
int socks5_server_method_set_method(socks5_server_method_t *inp, uint8_t val); int socks5_server_method_set_method(socks5_server_method_t *inp, uint8_t val);
/** Return a newly allocated socks5_server_userpath_auth with all /** Return a newly allocated socks5_server_userpass_auth with all
* elements set to zero. * elements set to zero.
*/ */
socks5_server_userpath_auth_t *socks5_server_userpath_auth_new(void); socks5_server_userpass_auth_t *socks5_server_userpass_auth_new(void);
/** Release all storage held by the socks5_server_userpath_auth in /** Release all storage held by the socks5_server_userpass_auth in
* 'victim'. (Do nothing if 'victim' is NULL.) * 'victim'. (Do nothing if 'victim' is NULL.)
*/ */
void socks5_server_userpath_auth_free(socks5_server_userpath_auth_t *victim); void socks5_server_userpass_auth_free(socks5_server_userpass_auth_t *victim);
/** Try to parse a socks5_server_userpath_auth from the buffer in /** Try to parse a socks5_server_userpass_auth from the buffer in
* 'input', using up to 'len_in' bytes from the input buffer. On * 'input', using up to 'len_in' bytes from the input buffer. On
* success, return the number of bytes consumed and set *output to the * success, return the number of bytes consumed and set *output to the
* newly allocated socks5_server_userpath_auth_t. On failure, return * newly allocated socks5_server_userpass_auth_t. On failure, return
* -2 if the input appears truncated, and -1 if the input is otherwise * -2 if the input appears truncated, and -1 if the input is otherwise
* invalid. * invalid.
*/ */
ssize_t socks5_server_userpath_auth_parse(socks5_server_userpath_auth_t **output, const uint8_t *input, const size_t len_in); ssize_t socks5_server_userpass_auth_parse(socks5_server_userpass_auth_t **output, const uint8_t *input, const size_t len_in);
/** Return the number of bytes we expect to need to encode the /** Return the number of bytes we expect to need to encode the
* socks5_server_userpath_auth in 'obj'. On failure, return a negative * socks5_server_userpass_auth in 'obj'. On failure, return a negative
* value. Note that this value may be an overestimate, and can even be * value. Note that this value may be an overestimate, and can even be
* an underestimate for certain unencodeable objects. * an underestimate for certain unencodeable objects.
*/ */
ssize_t socks5_server_userpath_auth_encoded_len(const socks5_server_userpath_auth_t *obj); ssize_t socks5_server_userpass_auth_encoded_len(const socks5_server_userpass_auth_t *obj);
/** Try to encode the socks5_server_userpath_auth from 'input' into /** Try to encode the socks5_server_userpass_auth from 'input' into
* the buffer at 'output', using up to 'avail' bytes of the output * the buffer at 'output', using up to 'avail' bytes of the output
* buffer. On success, return the number of bytes used. On failure, * buffer. On success, return the number of bytes used. On failure,
* return -2 if the buffer was not long enough, and -1 if the input * return -2 if the buffer was not long enough, and -1 if the input
* was invalid. * was invalid.
*/ */
ssize_t socks5_server_userpath_auth_encode(uint8_t *output, size_t avail, const socks5_server_userpath_auth_t *input); ssize_t socks5_server_userpass_auth_encode(uint8_t *output, size_t avail, const socks5_server_userpass_auth_t *input);
/** Check whether the internal state of the /** Check whether the internal state of the
* socks5_server_userpath_auth in 'obj' is consistent. Return NULL if * socks5_server_userpass_auth in 'obj' is consistent. Return NULL if
* it is, and a short message if it is not. * it is, and a short message if it is not.
*/ */
const char *socks5_server_userpath_auth_check(const socks5_server_userpath_auth_t *obj); const char *socks5_server_userpass_auth_check(const socks5_server_userpass_auth_t *obj);
/** Clear any errors that were set on the object 'obj' by its setter /** Clear any errors that were set on the object 'obj' by its setter
* functions. Return true iff errors were cleared. * functions. Return true iff errors were cleared.
*/ */
int socks5_server_userpath_auth_clear_errors(socks5_server_userpath_auth_t *obj); int socks5_server_userpass_auth_clear_errors(socks5_server_userpass_auth_t *obj);
/** Return the value of the version field of the /** Return the value of the version field of the
* socks5_server_userpath_auth_t in 'inp' * socks5_server_userpass_auth_t in 'inp'
*/ */
uint8_t socks5_server_userpath_auth_get_version(const socks5_server_userpath_auth_t *inp); uint8_t socks5_server_userpass_auth_get_version(const socks5_server_userpass_auth_t *inp);
/** Set the value of the version field of the /** Set the value of the version field of the
* socks5_server_userpath_auth_t in 'inp' to 'val'. Return 0 on * socks5_server_userpass_auth_t in 'inp' to 'val'. Return 0 on
* success; return -1 and set the error code on 'inp' on failure. * success; return -1 and set the error code on 'inp' on failure.
*/ */
int socks5_server_userpath_auth_set_version(socks5_server_userpath_auth_t *inp, uint8_t val); int socks5_server_userpass_auth_set_version(socks5_server_userpass_auth_t *inp, uint8_t val);
/** Return the value of the status field of the /** Return the value of the status field of the
* socks5_server_userpath_auth_t in 'inp' * socks5_server_userpass_auth_t in 'inp'
*/ */
uint8_t socks5_server_userpath_auth_get_status(const socks5_server_userpath_auth_t *inp); uint8_t socks5_server_userpass_auth_get_status(const socks5_server_userpass_auth_t *inp);
/** Set the value of the status field of the /** Set the value of the status field of the
* socks5_server_userpath_auth_t in 'inp' to 'val'. Return 0 on * socks5_server_userpass_auth_t in 'inp' to 'val'. Return 0 on
* success; return -1 and set the error code on 'inp' on failure. * success; return -1 and set the error code on 'inp' on failure.
*/ */
int socks5_server_userpath_auth_set_status(socks5_server_userpath_auth_t *inp, uint8_t val); int socks5_server_userpass_auth_set_status(socks5_server_userpass_auth_t *inp, uint8_t val);
/** Return a newly allocated tor_socksauth_keyval with all elements /** Return a newly allocated tor_socksauth_keyval with all elements
* set to zero. * set to zero.
*/ */

View File

@ -64,7 +64,7 @@ struct socks5_client_userpass_auth {
char passwd[passwd_len]; char passwd[passwd_len];
} }
struct socks5_server_userpath_auth { struct socks5_server_userpass_auth {
u8 version IN [1]; u8 version IN [1];
u8 status; u8 status;
} }