From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199712012109.QAA15700@rrdjazz.nist.gov> Date: Mon, 1 Dec 1997 16:09:27 -0500 From: Przemek Klosowski Subject: Re: Strange errors from strtok() Your CGI program #include #include char postline[80]; ... main() { .. while(gets(postline)!= NULL) { .. } } When I try to compile this program I get the following warnings: rsvp.c:20: warning: assignment makes pointer from integer without a cast rsvp.c:25: warning: assignment makes pointer from integer without a cast rsvp.c(.text+0x8c): the `gets' function is dangerous and should not be used. I would forget the pointer/integer problem for now; the third warning basically says that your CGI script is a wide-open security hole. The exploit: someone sends you a line exceeding 80 characters; gets() obediently overflows your measly 80 bytes and writes over other local variables, and then over the returning stack frame. With some cunning, the attackers put a fake stack frame pointing to a chunk of their code in the same overlong CGI line (it requires some skill, but is trivial otherwise). This results in them being able to run any code with the permissions/privileges of the web server process. You should be using fgets(), which will guarantee that your buffer will not overflow. As to your strtok() problems, you should be including . I think stdlib.h includes some but not all str... routines. Your code may have worked on Intel, but just fortuitously. In general, gcc -Wall is the right thing to do---it would have alerted you to lack of prototypes. It is good practice to resolve all warnings given by -Wall. -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com