Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added PC-lint Plus to Automated Detection Table

...

The following table summarizes the exit behavior of the program termination functions.

Function

Closes
Open
Streams

Flushes
Stream
Buffers

Removes
Temporary
Files

Calls
atexit()
Handlers

Program
Termination

abort()

(info)

(info) [2]

(info)

(error)

Abnormal

_Exit()

(info)

(info) [1]

(info)

(error)

Normal

exit()

(tick)

(tick)

(tick)

(tick)

Normal

Return from main()

(tick)

(tick)

(tick)

(tick)

Normal

Table legend:

  • (tick) – Yes. The specified action is performed.
  • (error) – No. The specified action is not performed.
  • (info)Implementation-defined. Whether the specified action is performed depends on the implementation.

...

As an example, using abort() or _Exit() in place of exit() may leave written files in an inconsistent state and may also leave sensitive temporary files on the file system.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

ERR04-C

Medium

Probable

High

P4

L3

Automated Detection

Tool

Version

Checker

Description

Parasoft C/C++test
Include Page
c:
Parasoft_V
c:
Parasoft_V
MISRA2012-RULE-21_8Use of getenv(), abort(), exit() and system()

CERT_C-ERR04-a
CERT_C-ERR04-b
CERT_C-ERR04-c

The 'abort()' function from the 'stdlib.h' or 'cstdlib' library shall not be used
The 'exit()' function from the 'stdlib.h' or 'cstdlib' library shall not be used
The 'quick_exit()' and '_Exit()' functions from the 'stdlib.h' or 'cstdlib' library shall not be used

PC-lint Plus

Include Page
PC-lint Plus_V
PC-lint Plus_V

586

Fully supported

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

Bibliography

[IEEE Std 1003.1:2013]XSH, System Interfaces, exit
[ISO/IEC 9899:2011]Subclause 5.1.2.2.3, "Program Termination"
Subclause 7.22.4, "Communication with the Environment"

...


...