diff options
author | Pauli <paul.dale@oracle.com> | 2018-07-04 09:30:43 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2018-07-11 09:03:22 +1000 |
commit | c9ecb13191fe902c1e78e3bca7c36c293bba4bc6 (patch) | |
tree | 41187ab74bc9d5c05b2a8df79d6fe2d2b44b3929 /test/conf_include_test.c | |
parent | 4431107d6c430950c2c2e19c03b8dff6355ccfdb (diff) |
NCONF_get_number refix.
Fix the NULL check lack in a different way that is more compatible with
non-NULL branch. Refer #6632
Also mark and pop the error stack instead of clearing all errors when something
goes awry in CONF_get_number.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6643)
Diffstat (limited to 'test/conf_include_test.c')
-rw-r--r-- | test/conf_include_test.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/conf_include_test.c b/test/conf_include_test.c index ba79d2c208..ee02d9b3fb 100644 --- a/test/conf_include_test.c +++ b/test/conf_include_test.c @@ -153,6 +153,31 @@ static int test_check_null_numbers(void) return 1; } +static int test_check_overflow(void) +{ +#if defined(_BSD_SOURCE) \ + || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \ + || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) + long val = 0; + char max[(sizeof(long) * 8) / 3 + 3]; + char *p; + + p = max + sprintf(max, "0%ld", LONG_MAX) - 1; + setenv("FNORD", max, 1); + if (!TEST_true(NCONF_get_number(NULL, "missing", "FNORD", &val)) + || !TEST_long_eq(val, LONG_MAX)) + return 0; + + while (++*p > '9') + *p-- = '0'; + + setenv("FNORD", max, 1); + if (!TEST_false(NCONF_get_number(NULL, "missing", "FNORD", &val))) + return 0; +#endif + return 1; +} + int setup_tests(void) { const char *conf_file; @@ -181,6 +206,7 @@ int setup_tests(void) ADD_TEST(test_load_config); ADD_TEST(test_check_null_numbers); + ADD_TEST(test_check_overflow); return 1; } |