Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider (sch jbop) (X_X)@==(Q_Q)@

...

Wiki Markup
In a hosted environment, the main function receives a third argument, {{char \*envp\[\]}}, that points to a nullNULL-terminated array of pointers to {{char}}, each of which points to a string that provides information about the environment for this execution of the program.

...

Code Block
extern char **environ;

/* ... */

int main(int argc, char const char *argv[], char const char *envp[]) {
   printf("environ:  %p\n", environ);
   printf("envp:     %p\n", envp);
   setenv("MY_NEW_VAR", "new_value", 1);
   puts("--Added MY_NEW_VAR--");
   printf("environ:  %p\n", environ);
   printf("envp:     %p\n", envp);
}

...

Code Block
bgColor#ffcccc
int main(int argc, char const char *argv[], char const char *envp[]) {
   size_t i;
   setenv("MY_NEW_VAR", "new_value", 1);
   if (envp != NULL) {
      for (i = 0; envp[i] != NULL; i++) {
         puts(envp[i]);
      }
   }
   return 0;
}

...

Code Block
bgColor#ccccff
extern char **environ;

/* ... */

int main(int argc, char const char *argv[]) {
   size_t i;
   setenv("MY_NEW_VAR", "new_value", 1);
   if (environ != NULL) {
      for (i = 0; environ[i] != NULL; i++) {
         puts(environ[i]);
      }
   }
   return 0;
}

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

ENV31-C

1 ( low ) 1 (

unlikely )

3 ( low )

P3

L3

Related Vulnerabilities

...