SELinuxProject / selint

Static code analysis of refpolicy style SELinux policy
Apache License 2.0
38 stars 17 forks source link

Check memory allocations #237

Closed cgzones closed 2 years ago

cgzones commented 2 years ago

Check all allocations for failures (OOM), not only to avoid mostly harmless NULL-dereferences, but also UB and memory corruption caused by optimizations.

See also: https://pvs-studio.com/en/blog/posts/cpp/0938/

Occurrences: grep -REw "(malloc|calloc|strdup|strndup|realloc|reallocarray)" src/

dburgener commented 2 years ago

I found the article mostly unconvincing, but I guess "We should allow undefined behavior" isn't a hill I want to die on, and the provided approach is pretty clean, so I'll take this. Thanks!