Merge "res_format_attr_opus: Fix crash when fmtp contains spaces." into 13

changes/93/4593/1
Kevin Harwell 9 years ago committed by Gerrit Code Review
commit f9644de0bd

@ -102,27 +102,35 @@ static int opus_clone(const struct ast_format *src, struct ast_format *dst)
static void sdp_fmtp_get(const char *attributes, const char *name, int *attr) static void sdp_fmtp_get(const char *attributes, const char *name, int *attr)
{ {
const char *kvp = ""; const char *kvp = attributes;
int val; int val;
if (attributes && !(kvp = strstr(attributes, name))) { if (ast_strlen_zero(attributes)) {
return; return;
} }
/* /* This logic goes through each attribute in the fmtp line looking for the
* If the named attribute is not at the start of the given attributes, and * requested named attribute.
* the preceding character is not a space or semicolon then it's not the
* attribute we are looking for. It's an attribute with the name embedded
* within it (e.g. ptime in maxptime, stereo in sprop-stereo).
*/ */
if (kvp != attributes && *(kvp - 1) != ' ' && *(kvp - 1) != ';') { while (*kvp) {
/* Keep searching as it might still be in the attributes string */ /* Skip any preceeding blanks as some implementations separate attributes using spaces too */
sdp_fmtp_get(strchr(kvp, ';'), name, attr); kvp = ast_skip_blanks(kvp);
/*
* Otherwise it's a match, so retrieve the value and set the attribute. /* If we are at at the requested attribute get its value and return */
*/ if (!strncmp(kvp, name, strlen(name)) && kvp[strlen(name)] == '=') {
} else if (sscanf(kvp, "%*[^=]=%30d", &val) == 1) { if (sscanf(kvp, "%*[^=]=%30d", &val) == 1) {
*attr = val; *attr = val;
break;
}
}
/* Move on to the next attribute if possible */
kvp = strchr(kvp, ';');
if (!kvp) {
break;
}
kvp++;
} }
} }

Loading…
Cancel
Save