diff options
author | Elliott Hughes <enh@google.com> | 2014-09-23 21:59:15 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-09-23 21:59:15 +0000 |
commit | 87b6906f6e0c17b2541535be8e054324cc2fef4a (patch) | |
tree | 64f418a870ba50ccec912a11f90605418f74c844 /tests/stdlib_test.cpp | |
parent | 8642165344217877b8a70811d19e09b584a0e10a (diff) | |
parent | b05ec5ae933987e6b4a4f6a318cb13e035ad33e9 (diff) | |
download | android_bionic-87b6906f6e0c17b2541535be8e054324cc2fef4a.tar.gz android_bionic-87b6906f6e0c17b2541535be8e054324cc2fef4a.tar.bz2 android_bionic-87b6906f6e0c17b2541535be8e054324cc2fef4a.zip |
Merge "Pull in upstream fixes to reject invalid bases."
Diffstat (limited to 'tests/stdlib_test.cpp')
-rw-r--r-- | tests/stdlib_test.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp index 553f018ed..667ccd6a4 100644 --- a/tests/stdlib_test.cpp +++ b/tests/stdlib_test.cpp @@ -361,3 +361,51 @@ TEST(stdlib, unlockpt_ENOTTY) { ASSERT_EQ(ENOTTY, errno); close(fd); } + +TEST(stdlib, strtol_EINVAL) { + errno = 0; + strtol("123", NULL, -1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtol("123", NULL, 1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtol("123", NULL, 37); + ASSERT_EQ(EINVAL, errno); +} + +TEST(stdlib, strtoll_EINVAL) { + errno = 0; + strtoll("123", NULL, -1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoll("123", NULL, 1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoll("123", NULL, 37); + ASSERT_EQ(EINVAL, errno); +} + +TEST(stdlib, strtoul_EINVAL) { + errno = 0; + strtoul("123", NULL, -1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoul("123", NULL, 1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoul("123", NULL, 37); + ASSERT_EQ(EINVAL, errno); +} + +TEST(stdlib, strtoull_EINVAL) { + errno = 0; + strtoull("123", NULL, -1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoull("123", NULL, 1); + ASSERT_EQ(EINVAL, errno); + errno = 0; + strtoull("123", NULL, 37); + ASSERT_EQ(EINVAL, errno); +} |