Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Rob Zook <rzook@informix.com>
Subject: Re: Strange errors from strtok()
Date: Mon, 01 Dec 1997 14:37:33 -0600	[thread overview]
Message-ID: <3.0.5.32.19971201143733.009a4d00@atlas> (raw)
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

       reply	other threads:[~1997-12-01 20:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <199712012014.NAA14201@ellpspace.math.ualberta.ca>
1997-12-01 20:37 ` Rob Zook [this message]
1997-12-01 22:15   ` Strange errors from strtok() Michal Jaegermann
1997-12-01 21:09 Przemek Klosowski
     [not found] <19971201115108.03468@dot.cygnus.com>
1997-12-01 20:16 ` Rob Zook
     [not found] <01bcfe7f$60288060$323ccbd0@zeke.bainet.com>
1997-12-01 19:03 ` Rob Zook
1997-12-01 19:51   ` Richard Henderson
1997-12-01 20:14   ` Michal Jaegermann
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox