From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <6d99e1c0bed6ec7401410004501a79b7.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199712012215.PAA14356@ellpspace.math.ualberta.ca> Date: Mon, 1 Dec 1997 15:15:40 -0700 (MST) From: Michal Jaegermann Subject: Re: Strange errors from strtok() In-Reply-To: <3.0.5.32.19971201143733.009a4d00@atlas> Rob Zook wrote: > >strtok() is not declared, .... > 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? strtok() is not declared, making compiler unhappy, but it still exists in libraries which are passed to a linker. Linker does not know anything about declarations and headers, it cares only about resolving symbols, so your program will link. Now compiler produced some code, assuming that all undeclared types defaulted to 'int' and this may, or may not, be what was expected. On 32-bit machine, where various integer types and pointers are all four byte wide, there is, unfortunately, a pretty good chance that all this fits and bugs are masked. But if your machine is 16-bit, or 64-bit - like Alpha, and a silent assumptions of "the same width" fails, you may be heading straight into a "crash and burn" land. > > 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. Using fgets() instead of gets() does not put much more burden on you nor requires a dynamic allocation. Do not forget about trailing '\0'. > 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. A little knowledge of a C programming is a very dangerous thing. The problem is not very personal as attested by numerous security bugs caused by buffer overflows and stack smashing. 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