Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC2012-Dir-4.14_i

In this section:
Synopsis

(Required) The validity of values received from external sources shall be checked.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

User input is used as a value in the environment.

Coding standards
MISRA C:2012 Dir-4.14

(Required) The validity of values received from external sources shall be checked

Code examples

The following code example fails the check and will give a warning:

#include <stdlib.h>

void example(void) {
  char *a = getenv("FOO");
  putenv(a);
}

The following code example passes the check and will not give a warning about this issue:

#include <stdlib.h>

void example(void) {
  char *a = getenv("FOO");
  a = "BAR";
  putenv(a);
}