276da39af9
Approved by: roberto, delphij Security: VuXML: 0d0f3050-1f69-11e5-9ba9-d050996490d0 Security: http://bugs.ntp.org/show_bug.cgi?id=2853 Security: https://www.kb.cert.org/vuls/id/668167 Security: http://support.ntp.org/bin/view/Main/SecurityNotice#June_2015_NTP_Security_Vulnerabi
52 lines
1019 B
C
52 lines
1019 B
C
#include "config.h"
|
|
|
|
#include "ntp_stdlib.h"
|
|
#include "ntp_calendar.h"
|
|
#include "unity.h"
|
|
|
|
void test_RegularPositive(void) {
|
|
const char *str = "17";
|
|
long val;
|
|
|
|
TEST_ASSERT_TRUE(atoint(str, &val));
|
|
TEST_ASSERT_EQUAL(17, val);
|
|
}
|
|
|
|
void test_RegularNegative(void) {
|
|
const char *str = "-20";
|
|
long val;
|
|
|
|
TEST_ASSERT_TRUE(atoint(str, &val));
|
|
TEST_ASSERT_EQUAL(-20, val);
|
|
}
|
|
|
|
void test_PositiveOverflowBoundary(void) {
|
|
const char *str = "2147483648";
|
|
long val;
|
|
|
|
TEST_ASSERT_FALSE(atoint(str, &val));
|
|
}
|
|
|
|
void test_NegativeOverflowBoundary(void) {
|
|
const char *str = "-2147483649";
|
|
long val;
|
|
|
|
TEST_ASSERT_FALSE(atoint(str, &val));
|
|
}
|
|
|
|
void test_PositiveOverflowBig(void) {
|
|
const char *str = "2300000000";
|
|
long val;
|
|
|
|
TEST_ASSERT_FALSE(atoint(str, &val));
|
|
}
|
|
|
|
void test_IllegalCharacter(void) {
|
|
const char *str = "4500l";
|
|
long val;
|
|
|
|
TEST_ASSERT_FALSE(atoint(str, &val));
|
|
}
|
|
|
|
|