File tree Expand file tree Collapse file tree
cpp/ql/test/query-tests/Security/CWE/CWE-253 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,4 +97,26 @@ void IncorrectTypeConversionTest() {
9797 {
9898 // ...
9999 }
100+
101+ if (HresultFunction () == S_FALSE ) // Correct Usage
102+ {
103+ // ...
104+ }
105+
106+ while (!HresultFunction ()) {}; // BUG
107+ while (FAILED (HresultFunction ())) {}; // Correct Usage
108+
109+ switch (hr ) // Correct Usage [FALSE POSITIVE]
110+ {
111+ case S_OK :
112+ case S_FALSE :
113+ {
114+ // ...
115+ } break ;
116+
117+ default :
118+ {
119+ // ...
120+ } break ;
121+ }
100122}
Original file line number Diff line number Diff line change @@ -94,4 +94,26 @@ void IncorrectTypeConversionTest() {
9494 {
9595 // ...
9696 }
97+
98+ if (HresultFunction () == S_FALSE) // Correct Usage
99+ {
100+ // ...
101+ }
102+
103+ while (!HresultFunction ()) {}; // BUG
104+ while (FAILED (HresultFunction ())) {}; // Correct Usage
105+
106+ switch (hr) // Correct Usage [FALSE POSITIVE]
107+ {
108+ case S_OK:
109+ case S_FALSE:
110+ {
111+ // ...
112+ } break ;
113+
114+ default :
115+ {
116+ // ...
117+ } break ;
118+ }
97119}
Original file line number Diff line number Diff line change 88| HResultBooleanConversion.c:79:15:79:38 | call to IncorrectHresultFunction | Implicit conversion from HRESULT to bool |
99| HResultBooleanConversion.c:82:10:82:11 | hr | Usage of a type HRESULT as an argument of a unary logical operation |
1010| HResultBooleanConversion.c:92:9:92:10 | hr | Direct usage of a type HRESULT as a conditional expression |
11+ | HResultBooleanConversion.c:106:13:106:27 | call to HresultFunction | Usage of a type HRESULT as an argument of a unary logical operation |
12+ | HResultBooleanConversion.c:109:12:109:13 | hr | Direct usage of a type HRESULT as a conditional expression |
1113| HResultBooleanConversion.cpp:39:12:39:23 | call to BoolFunction | Implicit conversion from BOOL to HRESULT |
1214| HResultBooleanConversion.cpp:44:12:44:24 | call to BoolFunction2 | Implicit conversion from bool to HRESULT |
1315| HResultBooleanConversion.cpp:50:15:50:16 | hr | Explicit conversion from HRESULT to BOOL |
1820| HResultBooleanConversion.cpp:76:15:76:38 | call to IncorrectHresultFunction | Implicit conversion from HRESULT to bool |
1921| HResultBooleanConversion.cpp:79:10:79:11 | hr | Implicit conversion from HRESULT to bool |
2022| HResultBooleanConversion.cpp:89:9:89:10 | hr | Implicit conversion from HRESULT to bool |
23+ | HResultBooleanConversion.cpp:103:13:103:27 | call to HresultFunction | Implicit conversion from HRESULT to bool |
24+ | HResultBooleanConversion.cpp:106:12:106:13 | hr | Direct usage of a type HRESULT as a conditional expression |
You can’t perform that action at this time.
0 commit comments