mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-10-15 18:58:48 +00:00
Revert "config-parser: Catch negative numbers assigned to unsigned config values"
The reduction in range limits does have an effect for color values,
which are expressed as hexadecimal values from 0x00000000 to
0xFFFFFFFF. By limiting the range to INT_MAX, color values of
0x80000000 and up are in fact lost.
This reverts commit 6351fb08c2
.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Yong Bakos <ybakos@humanoriented.com>
This commit is contained in:
parent
a8d987d93c
commit
03793e3998
|
@ -186,7 +186,6 @@ weston_config_section_get_uint(struct weston_config_section *section,
|
||||||
const char *key,
|
const char *key,
|
||||||
uint32_t *value, uint32_t default_value)
|
uint32_t *value, uint32_t default_value)
|
||||||
{
|
{
|
||||||
long int ret;
|
|
||||||
struct weston_config_entry *entry;
|
struct weston_config_entry *entry;
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
|
@ -198,22 +197,13 @@ weston_config_section_get_uint(struct weston_config_section *section,
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ret = strtol(entry->value, &end, 0);
|
*value = strtoul(entry->value, &end, 0);
|
||||||
if (errno != 0 || end == entry->value || *end != '\0') {
|
if (errno != 0 || end == entry->value || *end != '\0') {
|
||||||
*value = default_value;
|
*value = default_value;
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check range */
|
|
||||||
if (ret < 0 || ret > INT_MAX) {
|
|
||||||
*value = default_value;
|
|
||||||
errno = ERANGE;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*value = ret;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,6 @@ static struct zuc_fixture config_test_t1 = {
|
||||||
"# more comments\n"
|
"# more comments\n"
|
||||||
"number=5252\n"
|
"number=5252\n"
|
||||||
"zero=0\n"
|
"zero=0\n"
|
||||||
"negative=-42\n"
|
|
||||||
"flag=false\n"
|
"flag=false\n"
|
||||||
"\n"
|
"\n"
|
||||||
"[stuff]\n"
|
"[stuff]\n"
|
||||||
|
@ -462,36 +461,6 @@ ZUC_TEST_F(config_test_t1, test019, data)
|
||||||
ZUC_ASSERT_EQ(0, errno);
|
ZUC_ASSERT_EQ(0, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test020, data)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
int32_t n;
|
|
||||||
struct weston_config_section *section;
|
|
||||||
struct weston_config *config = data;
|
|
||||||
|
|
||||||
section = weston_config_get_section(config, "bar", NULL, NULL);
|
|
||||||
r = weston_config_section_get_int(section, "negative", &n, 600);
|
|
||||||
|
|
||||||
ZUC_ASSERT_EQ(0, r);
|
|
||||||
ZUC_ASSERT_EQ(-42, n);
|
|
||||||
ZUC_ASSERT_EQ(0, errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test021, data)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
uint32_t n;
|
|
||||||
struct weston_config_section *section;
|
|
||||||
struct weston_config *config = data;
|
|
||||||
|
|
||||||
section = weston_config_get_section(config, "bar", NULL, NULL);
|
|
||||||
r = weston_config_section_get_uint(section, "negative", &n, 600);
|
|
||||||
|
|
||||||
ZUC_ASSERT_EQ(-1, r);
|
|
||||||
ZUC_ASSERT_EQ(600, n);
|
|
||||||
ZUC_ASSERT_EQ(ERANGE, errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t2, doesnt_parse, data)
|
ZUC_TEST_F(config_test_t2, doesnt_parse, data)
|
||||||
{
|
{
|
||||||
struct weston_config *config = data;
|
struct weston_config *config = data;
|
||||||
|
|
Loading…
Reference in a new issue