char signed-ness bug in nl-web.c

Started by Cyril, November 09, 2009, 04:01:43 PM

Previous topic - Next topic

Cyril

newLISP (10.1.5 and 10.1.6 checked) failed to parse an HTTP answer if it contains 8-bit characters in headers. Well, according to RFC, there should be no 8-bit character in headers, but in real live there are. In particular, I cannot avoid them in my application (the server returning them is not under my control). Anyway, dependence of char signed-ness of C implementation is usually considered a bad style. In file nl-web.c:


/* socket send and receive routines with timeout */
int recvc_tm(int sock)
{
struct timeval tm;
char chr;

  // skipped

return(chr);
}


When 8-bit characters (I mean "which high bit set") are received from the socket, function returns a negative integer, which is treated as end-of-file later, leading to obscure error message. Replacing char chr; with unsigned char chr; has fixed the problem for me (I have compiled newLISP with MinGW under WinXP). I hope this (or similar) patch can be included in the next release. Thanks in advance!
With newLISP you can grow your lists from the right side!

Lutz

#1
Will be changed to 'unsigned char' for the next version.