Merge pull request #2729 from ar45/mod_curl_fix_argv

[mod_curl] Fix off-by-one error in argument limit checks.
This commit is contained in:
Andrey Volk 2025-01-15 23:43:23 +03:00 committed by GitHub
commit ca5b32701c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -898,7 +898,7 @@ SWITCH_STANDARD_APP(curl_app_function)
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
if (argc == 0) { if (argc == 0) {
switch_goto_status(SWITCH_STATUS_SUCCESS, usage); switch_goto_status(SWITCH_STATUS_SUCCESS, usage);
} else if (argc >= MOD_CURL_MAX_ARGS) { } else if (argc > MOD_CURL_MAX_ARGS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Max args exceeded: %d\n", MOD_CURL_MAX_ARGS); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Max args exceeded: %d\n", MOD_CURL_MAX_ARGS);
switch_goto_status(SWITCH_STATUS_FALSE, done); switch_goto_status(SWITCH_STATUS_FALSE, done);
} }
@ -1021,7 +1021,7 @@ SWITCH_STANDARD_API(curl_function)
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
if (argc < 1) { if (argc < 1) {
switch_goto_status(SWITCH_STATUS_SUCCESS, usage); switch_goto_status(SWITCH_STATUS_SUCCESS, usage);
} else if (argc >= MOD_CURL_MAX_ARGS) { } else if (argc > MOD_CURL_MAX_ARGS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Max args exceeded: %d\n", MOD_CURL_MAX_ARGS); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Max args exceeded: %d\n", MOD_CURL_MAX_ARGS);
switch_goto_status(SWITCH_STATUS_FALSE, done); switch_goto_status(SWITCH_STATUS_FALSE, done);
} }