Skip to content

Unchecked Return Value of Scanf Functions

Description

The software does not check the return value from scanf functions, which can prevent it from detecting unexpected states and conditions.

Examples

Insecure Code

c
scanf("%d", &x);

Secure Code

c
if (scanf("%d", &x) != 1) { handle_error(); }

Remediation

Check the return value of scanf functions to handle potential errors.

Rule Details

FieldValue
IDCODE-0488
CategoryInjection
SeverityMEDIUM
CWECWE-252
ConfidenceMEDIUM
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagsscanf, error handling
OWASPN/A

References