File tree Expand file tree Collapse file tree 3 files changed +35
-21
lines changed
cpp/ql/src/semmle/code/cpp/models Expand file tree Collapse file tree 3 files changed +35
-21
lines changed Original file line number Diff line number Diff line change @@ -9,5 +9,6 @@ private import implementations.Printf
99private import implementations.Pure
1010private import implementations.Strcat
1111private import implementations.Strcpy
12+ private import implementations.Strdup
1213private import implementations.Strftime
1314private import implementations.Swap
Original file line number Diff line number Diff line change @@ -173,32 +173,14 @@ class ReallocAllocationFunction extends AllocationFunction {
173173}
174174
175175/**
176- * An allocation function (such as `strdup`) that has no explicit argument for
176+ * A miscellaneous allocation function that has no explicit argument for
177177 * the size of the allocation.
178178 */
179- class StrdupAllocationFunction extends AllocationFunction {
180- StrdupAllocationFunction ( ) {
179+ class SizelessAllocationFunction extends AllocationFunction {
180+ SizelessAllocationFunction ( ) {
181181 exists ( string name |
182- hasGlobalOrStdName ( name ) and
183- (
184- // strdup(str)
185- name = "strdup"
186- or
187- // wcsdup(str)
188- name = "wcsdup"
189- )
190- or
191182 hasGlobalName ( name ) and
192183 (
193- // _strdup(str)
194- name = "_strdup"
195- or
196- // _wcsdup(str)
197- name = "_wcsdup"
198- or
199- // _mbsdup(str)
200- name = "_mbsdup"
201- or
202184 // ExAllocateFromLookasideListEx(list)
203185 name = "ExAllocateFromLookasideListEx"
204186 or
Original file line number Diff line number Diff line change 1+ import semmle.code.cpp.models.interfaces.Allocation
2+
3+ /**
4+ * A `strdup` style allocation function.
5+ */
6+ class StrdupFunction extends AllocationFunction {
7+ StrdupFunction ( ) {
8+ exists ( string name |
9+ hasGlobalOrStdName ( name ) and
10+ (
11+ // strdup(str)
12+ name = "strdup"
13+ or
14+ // wcsdup(str)
15+ name = "wcsdup"
16+ )
17+ or
18+ hasGlobalName ( name ) and
19+ (
20+ // _strdup(str)
21+ name = "_strdup"
22+ or
23+ // _wcsdup(str)
24+ name = "_wcsdup"
25+ or
26+ // _mbsdup(str)
27+ name = "_mbsdup"
28+ )
29+ )
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments