From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <3.0.5.32.19971201143733.009a4d00@atlas> Date: Mon, 01 Dec 1997 14:37:33 -0600 From: Rob Zook Subject: Re: Strange errors from strtok() In-Reply-To: <199712012014.NAA14201@ellpspace.math.ualberta.ca> At 01:14 PM 12/1/97 -0700, you wrote: >Rob Zook wrote: >> I'm trying to use the strtok function from stdlib in a program and > ^^^^^^^^^^^^^^^^^^^^ > strtok() is not in stdlib >> I get these strange errors: > >...therefore errors are not strange at all. Well, they seemed so to me at the time :-D. >> [rzook@babylon5 cgi-bin]$ cc -o rsvp rsvp.c >> rsvp.c: In function `main': >> rsvp.c:20: warning: assignment makes pointer from integer without a cast >> rsvp.c:25: warning: assignment makes pointer from integer without a cast > >strtok() is not declared, so compiler assumes a default 'int' as a type >of a return value. You try to assign this to a pointer. This is a bug >in your code. But why didn't I get some kind of link error? Why did it produce an executible at all if strtok was not declared or defined in my code? >> /tmp/cca197261.o: In function `main': >> rsvp.c(.text+0x8c): the `gets' function is dangerous and should not be used. > >Indeed! Anybody feeding your program a line longer than your buffer >will crash it or worse (manipulating your stack one can make your >program to execute any code at all). Big fun in a CGI context when >you apparently are heading. I know, gets() can produce dangerours results, and I plan to add a dynamic allocation for postline based on the results of CONTENT_LENGTH, but not while I'm testing. Besides, just using a pointer in c can cause dangerous results, so this message from the c compiler looks more like somebody at GNU's personal problem to me. Rob Z. -------------------------------------------------------- Not reaching a goal on a given day does not preclude reaching it tomorrow, or next year. One failure does not mean all is lost. Let it be motivation to improve, to deliver optimum performance in the next undertaking, whatever it may be - not to give up and quit trying. -- Capt. Spock -- 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