From ddc973344685b8fee1d7b00e23ba93692d56d7c9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 25 Aug 2013 18:24:53 +0200 Subject: audio: don't allow setting unknown formats from command line af_str2fmt_short(), which is used by the command line option parser, allowed passing a hex number. The user could set arbitrary integers as internal audio formats, even formats which don't exist or make no sense. This is not very useful, so get rid of it. --- audio/format.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'audio') diff --git a/audio/format.c b/audio/format.c index d98de9e5fd..aa6099022f 100644 --- a/audio/format.c +++ b/audio/format.c @@ -47,11 +47,7 @@ int af_fmt2bits(int format) char* af_fmt2str(int format, char* str, int size) { const char *name = af_fmt2str_short(format); - if (name) { - snprintf(str, size, "%s", name); - } else { - snprintf(str, size, "%#x", format); - } + snprintf(str, size, "%s", name); return str; } @@ -105,11 +101,6 @@ const char *af_fmt2str_short(int format) return "??"; } -static bool af_fmt_valid(int format) -{ - return (format & AF_FORMAT_MASK) == format; -} - int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate) { int bps = (af_fmt2bits(format) / 8); @@ -122,13 +113,6 @@ int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int sampler int af_str2fmt_short(bstr str) { - if (bstr_startswith0(str, "0x")) { - bstr rest; - int fmt = bstrtoll(str, &rest, 16); - if (rest.len == 0 && af_fmt_valid(fmt)) - return fmt; - } - for (int i = 0; af_fmtstr_table[i].name; i++) if (!bstrcasecmp0(str, af_fmtstr_table[i].name)) return af_fmtstr_table[i].format; -- cgit v1.2.3