Skip to content

Commit

Permalink
chan_voter.c: finddelim update to length of strp from str
Browse files Browse the repository at this point in the history
  • Loading branch information
mkmer committed Jan 30, 2025
1 parent e957e50 commit 504d262
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions channels/chan_voter.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ static int16_t deemp1(int16_t input, int32_t * restrict state0)
* \param limit Maximum number of substrings to process.
* \return Count of strings.
*/
static int finddelim(char *str, char *strp[], int limit)
static int finddelim(char *str, char *strp[], size_t limit)
{
int i, l, inquo;

Expand All @@ -799,7 +799,7 @@ static int finddelim(char *str, char *strp[], int limit)
strp[0] = 0;
return 0;
}
for (l = 0; *str && (l < limit); str++) {
for (l = 0; *str; str++) {
if (*str == QUOTECHR) {
if (inquo) {
*str = 0;
Expand All @@ -814,6 +814,9 @@ static int finddelim(char *str, char *strp[], int limit)
l++;
strp[i++] = str + 1;
}
if (i >= (limit - 1)) {
break;
}
}
strp[i] = 0;
return i;
Expand Down Expand Up @@ -2509,7 +2512,7 @@ static struct ast_channel *voter_request(const char *type, struct ast_format_cap
val = (char *) ast_variable_retrieve(cfg, (char *) data, "streams");
if (val) {
cp = ast_strdup(val);
p->nstreams = finddelim(cp, p->streams, MAXSTREAMS);
p->nstreams = finddelim(cp, p->streams, ARRAY_LEN(p->streams));
}
val = (char *) ast_variable_retrieve(cfg, (char *) data, "txctcss");
if (val) {
Expand Down Expand Up @@ -2538,7 +2541,7 @@ static struct ast_channel *voter_request(const char *type, struct ast_format_cap
if (!cp) {
return NULL;
}
j = finddelim(cp, strs, 2);
j = finddelim(cp, strs, ARRAY_LEN(strs));
if (j < 2) {
ast_log(LOG_ERROR, "Channel %s: primary not specified properly\n", ast_channel_name(tmp));
} else {
Expand All @@ -2565,7 +2568,7 @@ static struct ast_channel *voter_request(const char *type, struct ast_format_cap
val = (char *) ast_variable_retrieve(cfg, (char *) data, "thresholds");
if (val) {
cp = ast_strdup(val);
p->nthresholds = finddelim(cp, strs, MAXTHRESHOLDS);
p->nthresholds = finddelim(cp, strs, ARRAY_LEN(strs));
for (i = 0; i < p->nthresholds; i++) {
cp1 = strchr(strs[i], '=');
p->linger_thresh[i] = p->linger;
Expand Down Expand Up @@ -3193,7 +3196,7 @@ static int voter_do_txlockout(int fd, int argc, const char *const *argv)
}
} else { /* must be a comma-delimited list */
ast_copy_string(str, argv[3], sizeof(str) - 1);
n = finddelim((char *) argv[3], strs, 100);
n = finddelim((char *) argv[3], strs, ARRAY_LEN(strs));
for (i = 0; i < n; i++) {
if (!*strs[i]) {
continue;
Expand Down Expand Up @@ -3534,7 +3537,7 @@ static int manager_voter_status(struct mansession *ses, const struct message *m)
}
n = 0;
if (str) {
n = finddelim(str, strs, 100);
n = finddelim(str, strs, ARRAY_LEN(strs));
}
for (j = 1; j <= maxpvtorder; j++) {
for (p = pvts; p; p = p->next) {
Expand Down Expand Up @@ -5077,7 +5080,7 @@ static int reload(void)
p->nstreams = 0;
if (val) {
cp = ast_strdup(val);
p->nstreams = finddelim(cp, p->streams, MAXSTREAMS);
p->nstreams = finddelim(cp, p->streams, ARRAY_LEN(p->streams));
}
val = (char *) ast_variable_retrieve(cfg, (char *) data, "txctcss");
if (val) {
Expand Down Expand Up @@ -5107,7 +5110,7 @@ static int reload(void)
val = (char *) ast_variable_retrieve(cfg, (char *) data, "thresholds");
if (val) {
cp = ast_strdup(val);
p->nthresholds = finddelim(cp, strs, MAXTHRESHOLDS);
p->nthresholds = finddelim(cp, strs, ARRAY_LEN(strs));
for (i = 0; i < p->nthresholds; i++) {
cp1 = strchr(strs[i], '=');
p->linger_thresh[i] = p->linger;
Expand Down Expand Up @@ -5269,7 +5272,7 @@ static int reload(void)
ast_mutex_unlock(&voter_lock);
return -1;
}
n = finddelim(cp, strs, 40);
n = finddelim(cp, strs, ARRAY_LEN(strs));
if (n < 1) {
continue;
}
Expand Down

0 comments on commit 504d262

Please sign in to comment.