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:22:51 -0700

Sorry about that I noticed that I did not recompile before testing the last fix - the fix is wrong. The http.c code has no problem. It appends the data to the headers (one option is to never do this with small posts and always use the large post code that would fix it...). The other option is to check to not rewind with NTLM when sending small posts. There is probably better qualifying conditions for the rewindaftersend = TRUE in perhapsrewind for NTLM (determine that small post < 1024 bytes is being done then do not set it by checking http->postdata since this is how writesockfd is determined). But this should be able to be fixed higher up also, therefore I consider the resolution to this issue to be:
 
File: transfer.cFunction: Curl_readwriteOffending lines:infof(data, "Keep sending data to get tossed away!\n");k->keepon |= KEEP_WRITE;Replacement lines:infof(data, "Keep sending data to get tossed away!\n");if (conn->writesockfd != CURL_SOCKET_BAD) k->keepon |= KEEP_WRITE;
 
 
File: http.c
Function: perhapsrewind
Offending lines:
if(!conn->bits.authneg) conn->bits.rewindaftersend = TRUE;
Replacement lines:
if(!conn->bits.authneg && http->postdata) conn->bits.rewindaftersend = TRUE;
 
Thanks a lot for the help. Can these fixes be included in the next official cURL release 7.16.5?
 
-Greg

From: snatch_65_at_hotmail.comTo: curl-library_at_cool.haxx.seSubject: RE: cURL fails to POST to NTLM protected IIS6 server using ANY authentication with post < 1024bytesDate: 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 inFile: http.cFunction: Curl_httpSwitch case: HTTPREQ_POSTOffending 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!
_________________________________________________________________
PC Magazine’s 2007 editors’ choice for best web mail—award-winning Windows Live Hotmail.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HMWL_mini_pcmag_0707
Received on 2007-07-31