Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If either of the C Standard fgets() or fgetws() functions fail, the contents of the array being written is indeterminate. (See undefined behavior 170175.)  It is necessary to reset the string to a known value to avoid errors on subsequent string manipulation functions.

...

Making invalid assumptions about the contents of an array modified by fgets() or fgetws() can result in undefined behavior and 175 and abnormal program termination.

Rule

Severity

Likelihood

Detectable

RepairableRemediation Cost

Priority

Level

FIO40-C

Low

Probable

Yes

YesMedium

P4P6

L3L2

Automated Detection

Tool

Version

Checker

Description

CodeSonar
Include Page
CodeSonar_V
CodeSonar_V

LANG.MEM.UVAR

Uninitialized Variable
Cppcheck Premium

Include Page
Cppcheck Premium_V
Cppcheck Premium_V

premium-cert-fio40-c
Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

DF4861, DF4862, DF4863


LDRA tool suite
Include Page
LDRA_V
LDRA_V
44 SEnhanced enforcement
Parasoft C/C++test

Include Page
Parasoft_V
Parasoft_V

CERT_C-FIO40-a

Reset strings on fgets() or fgetws() failure

Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C: Rule FIO40-CChecks for use of indeterminate string (rule partially covered)
PVS-Studio

Include Page
PVS-Studio_V
PVS-Studio_V

V1024

Related Vulnerabilities

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

...