pcgi-wrapper.c bugs & programming oddities * The first error stems from using strlen and atol on a buffer which has not been null terminated. The program works because the programmer got lucky because the buffer is followed by a pointer which is initialized to zero and is never used. In "main": char t[10]={0}; should be char t[HDRLEN+1] = {0}; * Remove estatus & emsg, they are not used. * sizeof(char) is used liberally, but according to "The C Programming language" 2nd edition ANSI version. "sizeof(char) == 1", see Pg 204 under A7.4.8. When "sizeof(char)" is replaced by "1", the code simplifies nicely. * After "Receive stdout and stderr" buffers are allocated one byte larger than necessary and the whole buffer is cleared before the read. Both operations can be removed and the code cleaned up. Larry
+----[ Larry Luther ]--------------------------------------------- | pcgi-wrapper.c bugs & programming oddities | * sizeof(char) is used liberally, but according to | "The C Programming language" 2nd edition ANSI version. | "sizeof(char) == 1", see Pg 204 under A7.4.8. | When "sizeof(char)" is replaced by "1", the code | simplifies nicely. This would require Microsoft to adhere to standards... -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
On Mon, 24 Jan 2000, Larry Luther wrote:
pcgi-wrapper.c bugs & programming oddities
* The first error stems from using strlen and atol on a buffer which has not been null terminated. The program works because the programmer got lucky because the buffer is followed by a pointer which is initialized to zero and is never used.
In "main":
char t[10]={0}; should be char t[HDRLEN+1] = {0};
When I worked on mod_pcgi2 I caught and fixed the error, but I preferred not to touch pcgi-wraper.c...
* sizeof(char) is used liberally, but according to "The C Programming language" 2nd edition ANSI version. "sizeof(char) == 1", see Pg 204 under A7.4.8. When "sizeof(char)" is replaced by "1", the code simplifies nicely.
And I feel sometimes the code assumes sizeof(char) == 1 anyway... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd@phd.russ.ru Programmers don't die, they just GOSUB without RETURN.
participants (3)
-
Andrew Kenneth Milton -
Larry Luther -
Oleg Broytmann