mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
core, pulse, modules: Fix undefined behavior with array subscript of invalid type
From the NetBSD manual:
The first argument of these functions is of type int, but only a very
restricted subset of values are actually valid. The argument must either
be the value of the macro EOF (which has a negative value), or must be a
non-negative value within the range representable as unsigned char.
Passing invalid values leads to undefined behavior.
-- ctype(3)
This commit is contained in:
parent
9dd77827ad
commit
93cccdee8d
5 changed files with 15 additions and 15 deletions
|
|
@ -1442,7 +1442,7 @@ static bool contains_space(const char *string) {
|
||||||
pa_assert(string);
|
pa_assert(string);
|
||||||
|
|
||||||
for (p = string; *p; ++p) {
|
for (p = string; *p; ++p) {
|
||||||
if (isspace(*p))
|
if (isspace((unsigned char)*p))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -480,7 +480,7 @@ pa_proplist *pa_proplist_from_string(const char *s) {
|
||||||
goto success;
|
goto success;
|
||||||
else if (*p == '=')
|
else if (*p == '=')
|
||||||
goto fail;
|
goto fail;
|
||||||
else if (!isspace(*p)) {
|
else if (!isspace((unsigned char)*p)) {
|
||||||
key = p;
|
key = p;
|
||||||
state = KEY;
|
state = KEY;
|
||||||
key_len = 1;
|
key_len = 1;
|
||||||
|
|
@ -492,7 +492,7 @@ pa_proplist *pa_proplist_from_string(const char *s) {
|
||||||
goto fail;
|
goto fail;
|
||||||
else if (*p == '=')
|
else if (*p == '=')
|
||||||
state = VALUE_START;
|
state = VALUE_START;
|
||||||
else if (isspace(*p))
|
else if (isspace((unsigned char)*p))
|
||||||
state = AFTER_KEY;
|
state = AFTER_KEY;
|
||||||
else
|
else
|
||||||
key_len++;
|
key_len++;
|
||||||
|
|
@ -503,7 +503,7 @@ pa_proplist *pa_proplist_from_string(const char *s) {
|
||||||
goto fail;
|
goto fail;
|
||||||
else if (*p == '=')
|
else if (*p == '=')
|
||||||
state = VALUE_START;
|
state = VALUE_START;
|
||||||
else if (!isspace(*p))
|
else if (!isspace((unsigned char)*p))
|
||||||
goto fail;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -523,7 +523,7 @@ pa_proplist *pa_proplist_from_string(const char *s) {
|
||||||
state = VALUE_DOUBLE_QUOTES;
|
state = VALUE_DOUBLE_QUOTES;
|
||||||
value = p+1;
|
value = p+1;
|
||||||
value_len = 0;
|
value_len = 0;
|
||||||
} else if (!isspace(*p)) {
|
} else if (!isspace((unsigned char)*p)) {
|
||||||
state = VALUE_SIMPLE;
|
state = VALUE_SIMPLE;
|
||||||
value = p;
|
value = p;
|
||||||
value_len = 1;
|
value_len = 1;
|
||||||
|
|
@ -531,7 +531,7 @@ pa_proplist *pa_proplist_from_string(const char *s) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VALUE_SIMPLE:
|
case VALUE_SIMPLE:
|
||||||
if (*p == 0 || isspace(*p)) {
|
if (*p == 0 || isspace((unsigned char)*p)) {
|
||||||
if (proplist_setn(pl, key, key_len, value, value_len) < 0)
|
if (proplist_setn(pl, key, key_len, value, value_len) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
@ -610,7 +610,7 @@ pa_proplist *pa_proplist_from_string(const char *s) {
|
||||||
(*p >= 'A' && *p <= 'F') ||
|
(*p >= 'A' && *p <= 'F') ||
|
||||||
(*p >= 'a' && *p <= 'f')) {
|
(*p >= 'a' && *p <= 'f')) {
|
||||||
value_len++;
|
value_len++;
|
||||||
} else if (*p == 0 || isspace(*p)) {
|
} else if (*p == 0 || isspace((unsigned char)*p)) {
|
||||||
|
|
||||||
if (proplist_sethex(pl, key, key_len, value, value_len) < 0)
|
if (proplist_sethex(pl, key, key_len, value, value_len) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
||||||
|
|
@ -2332,7 +2332,7 @@ int pa_atou(const char *s, uint32_t *ret_u) {
|
||||||
pa_assert(ret_u);
|
pa_assert(ret_u);
|
||||||
|
|
||||||
/* strtoul() ignores leading spaces. We don't. */
|
/* strtoul() ignores leading spaces. We don't. */
|
||||||
if (isspace(*s)) {
|
if (isspace((unsigned char)*s)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -2376,7 +2376,7 @@ int pa_atol(const char *s, long *ret_l) {
|
||||||
pa_assert(ret_l);
|
pa_assert(ret_l);
|
||||||
|
|
||||||
/* strtol() ignores leading spaces. We don't. */
|
/* strtol() ignores leading spaces. We don't. */
|
||||||
if (isspace(*s)) {
|
if (isspace((unsigned char)*s)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -2421,7 +2421,7 @@ int pa_atod(const char *s, double *ret_d) {
|
||||||
pa_assert(ret_d);
|
pa_assert(ret_d);
|
||||||
|
|
||||||
/* strtod() ignores leading spaces. We don't. */
|
/* strtod() ignores leading spaces. We don't. */
|
||||||
if (isspace(*s)) {
|
if (isspace((unsigned char)*s)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ pa_void_func_t pa_load_sym(lt_dlhandle handle, const char *module, const char *s
|
||||||
sn = pa_sprintf_malloc("%s_LTX_%s", module, symbol);
|
sn = pa_sprintf_malloc("%s_LTX_%s", module, symbol);
|
||||||
|
|
||||||
for (c = sn; *c; c++)
|
for (c = sn; *c; c++)
|
||||||
if (!isalnum(*c))
|
if (!isalnum((unsigned char)*c))
|
||||||
*c = '_';
|
*c = '_';
|
||||||
|
|
||||||
f = (pa_void_func_t) lt_dlsym(handle, sn);
|
f = (pa_void_func_t) lt_dlsym(handle, sn);
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
|
||||||
case WHITESPACE:
|
case WHITESPACE:
|
||||||
if (*p == '=')
|
if (*p == '=')
|
||||||
goto fail;
|
goto fail;
|
||||||
else if (!isspace(*p)) {
|
else if (!isspace((unsigned char)*p)) {
|
||||||
key = p;
|
key = p;
|
||||||
state = KEY;
|
state = KEY;
|
||||||
key_len = 1;
|
key_len = 1;
|
||||||
|
|
@ -141,7 +141,7 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
|
||||||
case KEY:
|
case KEY:
|
||||||
if (*p == '=')
|
if (*p == '=')
|
||||||
state = VALUE_START;
|
state = VALUE_START;
|
||||||
else if (isspace(*p))
|
else if (isspace((unsigned char)*p))
|
||||||
goto fail;
|
goto fail;
|
||||||
else
|
else
|
||||||
key_len++;
|
key_len++;
|
||||||
|
|
@ -156,7 +156,7 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
|
||||||
state = VALUE_DOUBLE_QUOTES;
|
state = VALUE_DOUBLE_QUOTES;
|
||||||
value = p+1;
|
value = p+1;
|
||||||
value_len = 0;
|
value_len = 0;
|
||||||
} else if (isspace(*p)) {
|
} else if (isspace((unsigned char)*p)) {
|
||||||
if (add_key_value(ma,
|
if (add_key_value(ma,
|
||||||
pa_xstrndup(key, key_len),
|
pa_xstrndup(key, key_len),
|
||||||
pa_xstrdup(""),
|
pa_xstrdup(""),
|
||||||
|
|
@ -175,7 +175,7 @@ pa_modargs *pa_modargs_new(const char *args, const char* const* valid_keys) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VALUE_SIMPLE:
|
case VALUE_SIMPLE:
|
||||||
if (isspace(*p)) {
|
if (isspace((unsigned char)*p)) {
|
||||||
if (add_key_value(ma,
|
if (add_key_value(ma,
|
||||||
pa_xstrndup(key, key_len),
|
pa_xstrndup(key, key_len),
|
||||||
pa_xstrndup(value, value_len),
|
pa_xstrndup(value, value_len),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue