C++: Function error doesn't always exit

The configuration in `DefaultOptions.qll` assumed that a call to any
top-level function named `error` would exit the program. This is not
true.

The assumption was probably about `error(3)`, which is a GNU extension.
It only exits if its first argument it not 0. Furthermore, projects such
as openssh may define their own function named `error` with different
behaviour. Because the GNU `error` function is non-standard, it's
perfectly fine to shadow it with a project-specific definition.

This change removes two FPs from `PointlessComparison.qll` on
https://github.com/openssh/openssh-portable.
This commit is contained in:
Jonas Jensen
2019-02-26 16:18:52 +01:00
parent 86e646beb4
commit 07bd85e9fa
2 changed files with 2 additions and 3 deletions

View File

@@ -56,7 +56,7 @@ class Options extends string
* Holds if a call to this function will never return.
*
* By default, this holds for `exit`, `_exit`, `abort`, `__assert_fail`,
* `longjmp`, `error`, `__builtin_unreachable` and any function with a
* `longjmp`, `__builtin_unreachable` and any function with a
* `noreturn` attribute.
*/
predicate exits(Function f) {
@@ -67,7 +67,6 @@ class Options extends string
name = "abort" or
name = "__assert_fail" or
name = "longjmp" or
name = "error" or
name = "__builtin_unreachable"
) or
CustomOptions::exits(f) // old Options.qll