Created
January 11, 2026 17:00
-
-
Save CelDaemon/747f44042cb4c9fc0b4ee44f138c3d9d to your computer and use it in GitHub Desktop.
Program arg and environment dumper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <assert.h> | |
| #include <string.h> | |
| extern char **environ; | |
| char *get_env_end() { | |
| char *env_end = NULL; | |
| char *prev_end = NULL; | |
| int i = 0; | |
| do { | |
| prev_end = env_end; | |
| env_end = environ[i++]; | |
| } while(env_end != NULL); | |
| return prev_end + strlen(prev_end); | |
| } | |
| int main(int argc, char *argv[]) { | |
| fwrite(&argv[0][0], sizeof(char), get_env_end() - &argv[0][0], stdout); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment