Skip to content

Instantly share code, notes, and snippets.

@reporter123
Created January 15, 2018 01:52
Show Gist options
  • Save reporter123/30caef1ad4019efedcb591ea5669739d to your computer and use it in GitHub Desktop.
Save reporter123/30caef1ad4019efedcb591ea5669739d to your computer and use it in GitHub Desktop.
Hidden third parameter to main
#include<stdio.h>
int main(int argc, char** argv, char** env)
{
int i = 0;
while(env[i] != 0)
{
printf("%s\n", env[i++]);
}
return(0);
}
@reporter123
Copy link
Author

libc pass the environment as a third parameter to main on Linux and possibly other systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment