Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
int func() {
  char env[10];
  strcpy(env,"VAR=1");
  putenv(env);
  return 10;
}

int main (int argc, char * argv[]) {
  char *var;
  func();
  /* ... */
  var = getenv("VAR");
  return 0;
}

Compliant Solution

To make this example compliant env should not be declared with automatic storage.

...