aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/af_pan.c
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2012-09-14 12:45:34 -0400
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2012-09-15 19:49:34 -0400
commite3a1eb9edf65edda301f3a727f11e0224b9f5ae2 (patch)
tree8e44a00c97ec69e428d20160e877e6fa75f53b52 /libavfilter/af_pan.c
parentd512e74dec756787417b72776eece32466552724 (diff)
downloadffmpeg-e3a1eb9edf65edda301f3a727f11e0224b9f5ae2.tar.gz
af_pan: Fix sscanf formats to work with buggy sscanf implementations
Some implementations of sscanf do not handle a space before a trailing %n properly. As an example, MSVC's does this for the second insatnce in this patch, for an input of "0x3:c0=c1:c1=c0": 1) Match the final "c0" or "c1". 2) Realize it's at the end of the string. 3) Check for %n. 4) There is no %n, but a space instead. 5) Leave 'len' unitilialized. So, move it out of the sscanf format strings, and call skip_spaces instead. This bug does not affect skip_spaces since %n is the first and only formatting string. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavfilter/af_pan.c')
-rw-r--r--libavfilter/af_pan.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index 753522b76e..80a912e3ae 100644
--- a/libavfilter/af_pan.c
+++ b/libavfilter/af_pan.c
@@ -60,7 +60,7 @@ static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
int64_t layout, layout0;
/* try to parse a channel name, e.g. "FL" */
- if (sscanf(*arg, " %7[A-Z] %n", buf, &len)) {
+ if (sscanf(*arg, "%7[A-Z]%n", buf, &len)) {
layout0 = layout = av_get_channel_layout(buf);
/* channel_id <- first set bit in layout */
for (i = 32; i > 0; i >>= 1) {
@@ -78,7 +78,7 @@ static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
return 0;
}
/* try to parse a channel number, e.g. "c2" */
- if (sscanf(*arg, " c%d %n", &channel_id, &len) &&
+ if (sscanf(*arg, "c%d%n", &channel_id, &len) &&
channel_id >= 0 && channel_id < MAX_CHANNELS) {
*rchannel = channel_id;
*rnamed = 0;
@@ -143,6 +143,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args0)
"Invalid out channel name \"%.8s\"\n", arg0);
return AVERROR(EINVAL);
}
+ skip_spaces(&arg);
if (*arg == '=') {
arg++;
} else if (*arg == '<') {
@@ -156,7 +157,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args0)
/* gains */
while (1) {
gain = 1;
- if (sscanf(arg, " %lf %n* %n", &gain, &len, &len))
+ if (sscanf(arg, "%lf%n *%n", &gain, &len, &len))
arg += len;
if (parse_channel_name(&arg, &in_ch_id, &named)){
av_log(ctx, AV_LOG_ERROR,
@@ -170,6 +171,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args0)
return AVERROR(EINVAL);
}
pan->gain[out_ch_id][in_ch_id] = gain;
+ skip_spaces(&arg);
if (!*arg)
break;
if (*arg != '+') {
@@ -177,7 +179,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args0)
return AVERROR(EINVAL);
}
arg++;
- skip_spaces(&arg);
}
}
pan->need_renumber = !!nb_in_channels[1];