Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
Subject: Re: Strange errors from strtok()
Date: Mon, 1 Dec 1997 13:14:09 -0700 (MST)	[thread overview]
Message-ID: <e934b8330f400263bae16e519e129280.axp-list@archive.invalid> (raw)
In-Reply-To: <3.0.5.32.19971201130309.00913100@atlas>

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.

> [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.

> /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.

  Michal

-- 
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

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

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <01bcfe7f$60288060$323ccbd0@zeke.bainet.com>
1997-12-01 18:42 ` Unable to set UDB serial port speed RedHat4.2/2.0.30 Joakim Roubert
1997-12-01 19:03 ` Strange errors from strtok() Rob Zook
1997-12-01 19:51   ` Richard Henderson
1997-12-01 20:14   ` Michal Jaegermann [this message]
     [not found] <19971201115108.03468@dot.cygnus.com>
1997-12-01 20:16 ` Rob Zook
     [not found] <199712012014.NAA14201@ellpspace.math.ualberta.ca>
1997-12-01 20:37 ` Rob Zook
1997-12-01 22:15   ` Michal Jaegermann
1997-12-01 21:09 Przemek Klosowski
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