https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118656
Bug ID: 118656 Summary: glibc getenv returns the wrong result sometimes if the parameter contains '=' Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: MikeSmith32564 at mail dot com Target Milestone: --- #include <stdio.h> #include <stdlib.h> int main() { setenv("STR1", "NAME=VALUE", 1); char* result = getenv("STR1=NAME"); //expected "NULL", actual - "VALUE" printf(%s\n", (result ? result : "NULL")); } The getenv implementation doesn't check if the given parameter contains the '=' character, and so this can lead to results like this. More than one '=' used in the getenv call can also lead to these results.