Pull in upstream fixes to reject invalid bases.

Also add tests to make sure the full set works correctly.

Change-Id: I3e7f237f12c9c93e1185a97c9717803e7e55a73c
This commit is contained in:
Elliott Hughes
2014-09-23 14:53:10 -07:00
parent 8642165344
commit b05ec5ae93
9 changed files with 232 additions and 23 deletions

View File

@@ -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);
}