FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for mod_event_socket
This commit is contained in:
parent
4ae1f1278b
commit
e0211e2ce1
|
@ -906,6 +906,8 @@ SWITCH_STANDARD_API(event_sink_function)
|
||||||
|
|
||||||
edup = strdup(events);
|
edup = strdup(events);
|
||||||
|
|
||||||
|
switch_assert(edup);
|
||||||
|
|
||||||
if (strchr(edup, ' ')) {
|
if (strchr(edup, ' ')) {
|
||||||
delim = ' ';
|
delim = ' ';
|
||||||
}
|
}
|
||||||
|
@ -1295,7 +1297,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
||||||
val++;
|
val++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (var && val) {
|
if (val) {
|
||||||
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, var, val);
|
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, var, val);
|
||||||
if (!strcasecmp(var, "content-length")) {
|
if (!strcasecmp(var, "content-length")) {
|
||||||
clen = atoi(val);
|
clen = atoi(val);
|
||||||
|
@ -1581,9 +1583,7 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
|
||||||
switch_safe_free(stream.data);
|
switch_safe_free(stream.data);
|
||||||
switch_safe_free(freply);
|
switch_safe_free(freply);
|
||||||
|
|
||||||
if (acs->listener->rwlock) {
|
|
||||||
switch_thread_rwlock_unlock(acs->listener->rwlock);
|
switch_thread_rwlock_unlock(acs->listener->rwlock);
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
|
@ -1636,6 +1636,7 @@ static switch_bool_t auth_api_command(listener_t *listener, const char *api_cmd,
|
||||||
if (arg) {
|
if (arg) {
|
||||||
switch_safe_free(dup_arg);
|
switch_safe_free(dup_arg);
|
||||||
dup_arg = strdup(arg);
|
dup_arg = strdup(arg);
|
||||||
|
switch_assert(dup_arg);
|
||||||
check_cmd = dup_arg;
|
check_cmd = dup_arg;
|
||||||
if ((next = strchr(check_cmd, ' '))) {
|
if ((next = strchr(check_cmd, ' '))) {
|
||||||
*next++ = '\0';
|
*next++ = '\0';
|
||||||
|
@ -1762,7 +1763,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
|
|
||||||
user = cmd + 9;
|
user = cmd + 9;
|
||||||
|
|
||||||
if (user && (domain_name = strchr(user, '@'))) {
|
if ((domain_name = strchr(user, '@'))) {
|
||||||
*domain_name++ = '\0';
|
*domain_name++ = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1842,6 +1843,8 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
edup = strdup(allowed_events);
|
edup = strdup(allowed_events);
|
||||||
cur = edup;
|
cur = edup;
|
||||||
|
|
||||||
|
switch_assert(edup);
|
||||||
|
|
||||||
if (strchr(edup, ' ')) {
|
if (strchr(edup, ' ')) {
|
||||||
delim = ' ';
|
delim = ' ';
|
||||||
}
|
}
|
||||||
|
@ -1918,10 +1921,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
|
|
||||||
|
|
||||||
bot:
|
bot:
|
||||||
|
|
||||||
if (params) {
|
|
||||||
switch_event_destroy(¶ms);
|
switch_event_destroy(¶ms);
|
||||||
}
|
|
||||||
|
|
||||||
if (authed) {
|
if (authed) {
|
||||||
switch_set_flag_locked(listener, LFLAG_AUTHED);
|
switch_set_flag_locked(listener, LFLAG_AUTHED);
|
||||||
|
@ -2133,7 +2133,6 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(listener->session);
|
channel = switch_core_session_get_channel(listener->session);
|
||||||
|
|
||||||
if (onoff) {
|
|
||||||
while (*onoff == ' ') {
|
while (*onoff == ' ') {
|
||||||
onoff++;
|
onoff++;
|
||||||
}
|
}
|
||||||
|
@ -2143,7 +2142,6 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
} else {
|
} else {
|
||||||
strip_cr(onoff);
|
strip_cr(onoff);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (zstr(onoff)) {
|
if (zstr(onoff)) {
|
||||||
switch_snprintf(reply, reply_len, "-ERR missing value.");
|
switch_snprintf(reply, reply_len, "-ERR missing value.");
|
||||||
|
@ -2173,7 +2171,6 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
async = 1;
|
async = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uuid) {
|
|
||||||
while (*uuid == ' ') {
|
while (*uuid == ' ') {
|
||||||
uuid++;
|
uuid++;
|
||||||
}
|
}
|
||||||
|
@ -2183,7 +2180,6 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
} else {
|
} else {
|
||||||
strip_cr(uuid);
|
strip_cr(uuid);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (zstr(uuid)) {
|
if (zstr(uuid)) {
|
||||||
uuid = switch_event_get_header(*event, "session-id");
|
uuid = switch_event_get_header(*event, "session-id");
|
||||||
|
@ -2286,6 +2282,8 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
char *arg_copy = NULL;
|
char *arg_copy = NULL;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
|
||||||
|
switch_assert(api_copy);
|
||||||
|
|
||||||
if ((arg_copy = strchr(api_copy, ' '))) {
|
if ((arg_copy = strchr(api_copy, ' '))) {
|
||||||
*arg_copy++ = '\0';
|
*arg_copy++ = '\0';
|
||||||
}
|
}
|
||||||
|
@ -2348,9 +2346,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
acs->listener = listener;
|
acs->listener = listener;
|
||||||
acs->console_execute = 0;
|
acs->console_execute = 0;
|
||||||
|
|
||||||
if (api_cmd) {
|
|
||||||
acs->api_cmd = switch_core_strdup(acs->pool, api_cmd);
|
acs->api_cmd = switch_core_strdup(acs->pool, api_cmd);
|
||||||
}
|
|
||||||
if (arg) {
|
if (arg) {
|
||||||
acs->arg = switch_core_strdup(acs->pool, arg);
|
acs->arg = switch_core_strdup(acs->pool, arg);
|
||||||
}
|
}
|
||||||
|
@ -2457,7 +2453,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
strip_cr(cmd);
|
strip_cr(cmd);
|
||||||
cur = cmd + 5;
|
cur = cmd + 5;
|
||||||
|
|
||||||
if (cur && (cur = strchr(cur, ' '))) {
|
if ((cur = strchr(cur, ' '))) {
|
||||||
for (cur++; cur; count++) {
|
for (cur++; cur; count++) {
|
||||||
switch_event_types_t type;
|
switch_event_types_t type;
|
||||||
|
|
||||||
|
@ -2539,7 +2535,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even
|
||||||
strip_cr(cmd);
|
strip_cr(cmd);
|
||||||
cur = cmd + 8;
|
cur = cmd + 8;
|
||||||
|
|
||||||
if (cur && (cur = strchr(cur, ' '))) {
|
if ((cur = strchr(cur, ' '))) {
|
||||||
for (cur++; cur; count++) {
|
for (cur++; cur; count++) {
|
||||||
switch_event_types_t type;
|
switch_event_types_t type;
|
||||||
|
|
||||||
|
@ -3026,7 +3022,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
|
||||||
|
|
||||||
if (switch_socket_addr_get(&listener->sa, SWITCH_TRUE, listener->sock) == SWITCH_STATUS_SUCCESS && listener->sa) {
|
if (switch_socket_addr_get(&listener->sa, SWITCH_TRUE, listener->sock) == SWITCH_STATUS_SUCCESS && listener->sa) {
|
||||||
switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), listener->sa);
|
switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), listener->sa);
|
||||||
if (listener->sa && (listener->remote_port = switch_sockaddr_get_port(listener->sa))) {
|
if ((listener->remote_port = switch_sockaddr_get_port(listener->sa))) {
|
||||||
launch_listener_thread(listener);
|
launch_listener_thread(listener);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue