1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-02-04 06:08:26 +02:00

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>
This commit is contained in:
Hendrik Leppkes 2012-09-14 12:45:34 -04:00 committed by Derek Buitenhuis
parent d512e74dec
commit e3a1eb9edf

View File

@ -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 == '<') {
@ -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];