Vulnerability Development mailing list archives

Re: argc issue


From: Valdis.Kletnieks () vt edu
Date: Thu, 25 May 2006 12:48:00 -0400

On Tue, 23 May 2006 19:51:58 +0200, padre () correo ugr es said:

 if (argc)
    exit (-1);
 else {
      strcpy(a,argv[1]);
      }

Buggy code.  It's basically saying "If there's arguments to the program,
exit. Otherwise, copy the (implicitly non-existent) first argument to 'a'".

But the main issue is " if (argc) exit(0);" . How can I change the argc
variable so it contais the value of 0?.

Fix your code, I think you wanted 'if (!argc) exit (-1);'

That's probably easier than trying to over-ride the system startup code
that creates the argc value and passes it to main() (on Linux/Unix boxes,
usually in a stub called crt0.o or similar).  Lots of tricky system-dependent
code in there, it's not for the faint of heart.

Attachment: _bin
Description:


Current thread: