care about the argv array when the filename is passed

remote-dns
rofl0r 2011-09-10 23:05:07 +02:00
parent a9df8ecaaa
commit c377789d14
1 changed files with 7 additions and 1 deletions

View File

@ -44,6 +44,7 @@ int main(int argc, char *argv[]) {
char buf[256]; char buf[256];
char pbuf[256]; char pbuf[256];
int opt; int opt;
int start_argv = 1;
while ((opt = getopt(argc, argv, "fh:")) != -1) { while ((opt = getopt(argc, argv, "fh:")) != -1) {
switch (opt) { switch (opt) {
@ -52,6 +53,11 @@ int main(int argc, char *argv[]) {
break; break;
case 'f': case 'f':
path = (char *)optarg; path = (char *)optarg;
if(!path) {
printf("error: no path supplied.");
return(EXIT_FAILURE);
}
start_argv = 3;
break; break;
default: /* '?' */ default: /* '?' */
usage(argv); usage(argv);
@ -93,7 +99,7 @@ int main(int argc, char *argv[]) {
snprintf(buf, sizeof(buf), "LD_PRELOAD=%s/libproxychains.so", LIB_DIR); snprintf(buf, sizeof(buf), "LD_PRELOAD=%s/libproxychains.so", LIB_DIR);
putenv(buf); putenv(buf);
execvp(argv[1], &argv[1]); execvp(argv[start_argv], &argv[start_argv]);
perror("proxychains can't load process...."); perror("proxychains can't load process....");
return EXIT_FAILURE; return EXIT_FAILURE;