Created
April 14, 2013 09:48
-
-
Save seveas/5382136 to your computer and use it in GitHub Desktop.
This file contains 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 <string.h> | |
#include <unistd.h> | |
void print_cmdline(void); | |
int main(int argc, char **argv) { | |
char *end; | |
print_cmdline(); | |
end = argv[argc-1] + strlen(argv[argc-1]); | |
memset(*argv, 'X', end-*argv); | |
print_cmdline(); | |
return 0; | |
} | |
void print_cmdline() { | |
FILE* fd = fopen("/proc/self/cmdline", "r"); | |
char buf[1024]; | |
size_t len = fread(buf, 1, 1023, fd); | |
buf[len] = '\n'; | |
fwrite(buf, len+1, 1, stdout); | |
fflush(stdout); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment