31. January 2012 08:00
A short code example to show how to overwrite the contents of argv. It is useful for when a password is passed on the command line and it should not be visible in the process list to other users on the same machine.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
int i = 0;
int len = 0;
if (argc < 2) {
printf("Usage: %s <some argument>\n", argv[0]);
exit(EXIT_FAILURE);
}
len = strlen(argv[1]);
for(i=0;i<len;i++) {
argv[1][i] = 'x';
}
system("ps f");
return 0;
}
86a2d7d8-01d0-45c7-8d27-1328339f8fde|0|.0