Skip to content

Commit c537c1b

Browse files
committed
Rust: correct CWE-770 GlobalAlloc MISSING comments
The `System.alloc`/`alloc_zeroed`/`realloc` sinks stopped matching because the standard library made `GlobalAlloc` a legacy trait blanket-implemented for `GlobalAllocator` types. These calls now resolve to the blanket-impl methods, which have no canonical path, so the `GlobalAlloc::*` sink models miss them. This is a QL/model matching gap, not a rust-analyzer resolution failure.
1 parent 6dfacd0 commit c537c1b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • rust/ql/test/query-tests/security/CWE-770

rust/ql/test/query-tests/security/CWE-770/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ unsafe fn test_system_alloc(v: usize) {
190190
let _ = std::alloc::Global.allocate_zeroed(l1).unwrap();
191191

192192
let l2 = std::alloc::Layout::array::<u8>(v).unwrap();
193-
// RA 0.0.347 no longer resolves the `GlobalAlloc` methods `System.alloc`/`alloc_zeroed`/`realloc`,
194-
// so these sinks are no longer detected; tracked as MISSING pending a fix.
193+
// `GlobalAlloc` is a legacy trait, blanket-implemented for `GlobalAllocator` types, so these
194+
// resolve to the blanket impl whose methods have no canonical path; the sink models miss them.
195195
let _ = std::alloc::System.alloc(l2); // $ MISSING: Alert[rust/uncontrolled-allocation-size]=arg1
196196
let _ = std::alloc::System.alloc_zeroed(l2); // $ MISSING: Alert[rust/uncontrolled-allocation-size]=arg1
197197
let _ = std::alloc::System.allocate(l2).unwrap(); // $ Alert[rust/uncontrolled-allocation-size]=arg1
@@ -201,7 +201,7 @@ unsafe fn test_system_alloc(v: usize) {
201201

202202
let l3 = std::alloc::Layout::array::<u8>(10).unwrap();
203203
let m3 = std::alloc::System.alloc(l3);
204-
// `System.realloc` unresolved by RA 0.0.347 (see note above); tracked as MISSING.
204+
// `System.realloc` resolves to that same `GlobalAlloc` blanket impl (see above); MISSING.
205205
let _ = std::alloc::System.realloc(m3, l3, v); // $ MISSING: Alert[rust/uncontrolled-allocation-size]=arg1
206206

207207
let l4 = std::alloc::Layout::array::<u8>(10).unwrap();

0 commit comments

Comments
 (0)