mirror of
https://github.com/darkk/redsocks.git
synced 2025-08-30 21:55:31 +00:00
Fix logic error bugs.
scan-build result for socks5.c:256: Function call argument is an uninitialized value nextstate can be undefined reply's addrtype field has unexpected value. Fix by adding else case before to report error, drop client and return from socks5_read_reply() function. scan-build result for main.c:144, parser.c:193: Result of operation is garbage or undefined If there is early error in main() in second FOREACH block, then terminators array is not itialized before access in shutdown path. Fix by moving memset() to precede this block. gettoken() does not initialize copytype enum value, so can have a garbage value at some point. Add else case to the chain of **iter tests to report error and return from the function.
This commit is contained in:
parent
c82e944cba
commit
39b2639bdb
2
main.c
2
main.c
@ -104,6 +104,7 @@ int main(int argc, char **argv)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
event_init();
|
||||
memset(terminators, 0, sizeof(terminators));
|
||||
|
||||
FOREACH(ss, subsystems) {
|
||||
if ((*ss)->init) {
|
||||
@ -124,7 +125,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
assert(SIZEOF_ARRAY(exit_signals) == SIZEOF_ARRAY(terminators));
|
||||
memset(terminators, 0, sizeof(terminators));
|
||||
for (i = 0; i < SIZEOF_ARRAY(exit_signals); i++) {
|
||||
signal_set(&terminators[i], exit_signals[i], terminate, NULL);
|
||||
if (signal_add(&terminators[i], NULL) != 0) {
|
||||
|
4
parser.c
4
parser.c
@ -183,6 +183,10 @@ static char *gettoken(parser_context *context, char **iter)
|
||||
copytype = gt_plainstr;
|
||||
len = 2;
|
||||
}
|
||||
else {
|
||||
parser_error(context, "unexpected char");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = malloc(len + 1);
|
||||
if (!ret) {
|
||||
|
5
socks5.c
5
socks5.c
@ -252,6 +252,11 @@ static void socks5_read_reply(struct bufferevent *buffev, redsocks_client *clien
|
||||
len = sizeof(domain.size);
|
||||
nextstate = socks5_skip_domain;
|
||||
}
|
||||
else {
|
||||
redsocks_log_error(client, LOG_NOTICE, "Socks5 server reported unexpected address type...");
|
||||
redsocks_drop_client(client);
|
||||
return;
|
||||
}
|
||||
|
||||
redsocks_write_helper(
|
||||
buffev, client,
|
||||
|
Loading…
Reference in New Issue
Block a user