diff options
author | wm4 <wm4@nowhere> | 2014-07-01 23:10:38 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-07-01 23:11:08 +0200 |
commit | 9a210ca2d50e02bf045866bbb2f44a33a3c48cd9 (patch) | |
tree | 9f685c66c9d3b2e968416c7f60d30ea56ab1f9bb /stream/stream_dvb.c | |
parent | 0208ad4f3b4d2331b8242bb6fb12a9a4475ccae6 (diff) | |
download | mpv-9a210ca2d50e02bf045866bbb2f44a33a3c48cd9.tar.bz2 mpv-9a210ca2d50e02bf045866bbb2f44a33a3c48cd9.tar.xz |
Audit and replace all ctype.h uses
Something like "char *s = ...; isdigit(s[0]);" triggers undefined
behavior, because char can be signed, and thus s[0] can be a negative
value. The is*() functions require unsigned char _or_ EOF. EOF is a
special value outside of unsigned char range, thus the argument to the
is*() functions can't be a char.
This undefined behavior can actually trigger crashes if the
implementation of these functions e.g. uses lookup tables, which are
then indexed with out-of-range values.
Replace all <ctype.h> uses with our own custom mp_is*() functions added
with misc/ctype.h. As a bonus, these functions are locale-independent.
(Although currently, we _require_ C locale for other reasons.)
Diffstat (limited to 'stream/stream_dvb.c')
-rw-r--r-- | stream/stream_dvb.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index d6ebddb944..87b2495a51 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -34,7 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <ctype.h> #include <sys/ioctl.h> #include <sys/time.h> #include <poll.h> @@ -45,6 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include <libavutil/avstring.h> #include "osdep/io.h" +#include "misc/ctype.h" #include "stream.h" #include "options/m_config.h" @@ -177,7 +177,7 @@ static dvb_channels_list *dvb_get_channels(struct mp_log *log, char *filename, i { fields = sscanf(&line[k], sat_conf, &ptr->freq, &ptr->pol, &ptr->diseqc, &ptr->srate, vpid_str, apid_str); - ptr->pol = toupper(ptr->pol); + ptr->pol = mp_toupper(ptr->pol); ptr->freq *= 1000UL; ptr->srate *= 1000UL; ptr->tone = -1; |