cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: cURL fails to POST to NTLM protected IIS6 server using ANY authentication with post < 1024bytes

From: Greg Morse <snatch_65_at_hotmail.com>
Date: Tue, 31 Jul 2007 11:01:11 -0700

Okay let me explain - I think I fully understand what is going on now.
 
The socket never turned bad it was bad from the beginning. In http.c in function Curl_http there is a comparison for the HTTPREQ_POST area with MAX_INITIAL_POST_SIZE. If less than MAX_INITIAL_POST_SIZE (1024 bytes like mentioned) then we do not set http->postdata. If we do not set http->postdata then further down when Curl_transfer is called, we do not set a writesockfd. If we do not set a writesockfd, then ANY negotiating to NTLM can allow a rewind which will set KEEP_WRITE flag and cause indefinite loop in Curl_transfer.
 
I do not know how you want to fix this (the first fix you correctly ignored with the .want == NTLM stuff is wrong...) but I still recommend the second fix since you check that the socket is not bad before reenabling in other places in the code as well:> > infof(data, "Keep sending data to get tossed away!\n");if (conn->writesockfd > > != CURL_SOCKET_BAD) k->keepon |= KEEP_WRITE;
 
My other suggestion is to change the code in
File: http.c
Function: Curl_http
Switch case: HTTPREQ_POST
Offending line:
        result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount, http->postdata?FIRSTSOCKET:-1, http->postdata?&http->writebytecount:NULL);
Fix by always setting the write socket for posts even when small (does it for large and callback posts):
        result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount, FIRSTSOCKET, &http->writebytecount);
Both of these fixes seem appropriate to me. Since even if the bad socket check fix is a sign of a higher up bug it is probably still a good idea to try to prevent infinite loops in general...
-Greg
_________________________________________________________________
Local listings, incredible imagery, and driving directions - all in one place! Find it!
http://maps.live.com/?wip=69&FORM=MGAC01
Received on 2007-07-31