Skip to content

Commit 4df176a

Browse files
committed
CPP: Add test coverage for isModifiedByArithmeticOperation.
1 parent f12c057 commit 4df176a

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

cpp/ql/test/query-tests/Likely Bugs/Leap Year/UncheckedLeapYearAfterYearModification/UncheckedLeapYearAfterYearModification.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
| test.cpp:636:11:636:17 | tm_year | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:56:6:56:12 | tm_year | tm_year | test.cpp:628:12:628:19 | timeinfo | timeinfo |
1010
| test.cpp:640:5:640:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:629:13:629:14 | st | st |
1111
| test.cpp:642:5:642:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:629:13:629:14 | st | st |
12+
| test.cpp:718:5:718:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:712:13:712:14 | st | st |
13+
| test.cpp:731:5:731:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:725:13:725:14 | st | st |
14+
| test.cpp:732:5:732:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:725:13:725:14 | st | st |
15+
| test.cpp:733:5:733:9 | wYear | Field $@ on variable $@ has been modified, but no appropriate check for LeapYear was found. | test.cpp:12:7:12:11 | wYear | wYear | test.cpp:725:13:725:14 | st | st |
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
| test.cpp:317:2:317:21 | call to SystemTimeToFileTime | Return value of $@ function should be verified to check for any error because variable $@ is not guaranteed to be safe. | test.cpp:63:1:63:20 | SystemTimeToFileTime | SystemTimeToFileTime | test.cpp:309:13:309:14 | st | st |
22
| test.cpp:330:2:330:21 | call to SystemTimeToFileTime | Return value of $@ function should be verified to check for any error because variable $@ is not guaranteed to be safe. | test.cpp:63:1:63:20 | SystemTimeToFileTime | SystemTimeToFileTime | test.cpp:322:13:322:14 | st | st |
33
| test.cpp:341:2:341:21 | call to SystemTimeToFileTime | Return value of $@ function should be verified to check for any error because variable $@ is not guaranteed to be safe. | test.cpp:63:1:63:20 | SystemTimeToFileTime | SystemTimeToFileTime | test.cpp:333:62:333:63 | st | st |
4+
| test.cpp:720:2:720:21 | call to SystemTimeToFileTime | Return value of $@ function should be verified to check for any error because variable $@ is not guaranteed to be safe. | test.cpp:63:1:63:20 | SystemTimeToFileTime | SystemTimeToFileTime | test.cpp:712:13:712:14 | st | st |
5+
| test.cpp:735:2:735:21 | call to SystemTimeToFileTime | Return value of $@ function should be verified to check for any error because variable $@ is not guaranteed to be safe. | test.cpp:63:1:63:20 | SystemTimeToFileTime | SystemTimeToFileTime | test.cpp:725:13:725:14 | st | st |

cpp/ql/test/query-tests/Likely Bugs/Leap Year/UncheckedLeapYearAfterYearModification/test.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,57 @@ void mkDateTest(int year)
680680
}
681681
// ...
682682
}
683+
684+
void unmodified1()
685+
{
686+
SYSTEMTIME st;
687+
FILETIME ft;
688+
WORD w;
689+
690+
GetSystemTime(&st);
691+
692+
w = st.wYear;
693+
694+
SystemTimeToFileTime(&st, &ft); // GOOD - no modification
695+
}
696+
697+
void unmodified2()
698+
{
699+
SYSTEMTIME st;
700+
FILETIME ft;
701+
WORD *w_ptr;
702+
703+
GetSystemTime(&st);
704+
705+
w_ptr = &(st.wYear);
706+
707+
SystemTimeToFileTime(&st, &ft); // GOOD - no modification
708+
}
709+
710+
void modified3()
711+
{
712+
SYSTEMTIME st;
713+
FILETIME ft;
714+
WORD *w_ptr;
715+
716+
GetSystemTime(&st);
717+
718+
st.wYear = st.wYear + 1;
719+
720+
SystemTimeToFileTime(&st, &ft); // BAD
721+
}
722+
723+
void modified4()
724+
{
725+
SYSTEMTIME st;
726+
FILETIME ft;
727+
WORD *w_ptr;
728+
729+
GetSystemTime(&st);
730+
731+
st.wYear++;
732+
st.wYear++;
733+
st.wYear++;
734+
735+
SystemTimeToFileTime(&st, &ft); // BAD
736+
}

0 commit comments

Comments
 (0)