-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Description
#![no_main]
#[no_mangle]
#[allow(non_upper_case_globals)]
pub static main: [f64; 7] = [
-2.524355105561429e-29,
-1.300510625000004e5,
3.2984344530918e-310,
4.138422214507362e199,
5.843108278877813e257,
8.69972257894351e183,
1.979474603311587e-258
];When compiled, no warnings are issued and when run it prints "Main is usually a function". As I understand this code is just arbitrary bytes being interpreted as code since it has the main symbol. While unlikely to be seen in real code, this is still a way for any arbitrary (unsafe) code to be run without unsafe.
I would have expected at least a warning that a "special" symbol ("main", are there other important ones to consider?) was specified with #[no_mangle] and was not a function. Or maybe arbitrary bytes for "special" symbols must be in an unsafe block to try to avoid this.
Metadata
Metadata
Assignees
Labels
No labels