EventLog error Unable to get server variable 'HTTP_COOKIE'

Jun 11, 2009 at 1:10 PM

Hello Tiago,

Thanks a lot for this easy to use solution for writing ISAPI filters. I have written my own little filter that basically subscribes to the PreProcHeaders event and then the Log event.  In the PreProcHeaders event I attempt to get at the cookie string by using the following

e.Context.ServerVariables[ServerVariable.HTTP_COOKIE];

I then grab the neccesary key and string out of the cookie string and populate a variable that is used in the Log event to write  the clientusername in the IISLog(cs-username).  This process works and the IIS logs are being populated correctly, but more often than not my eventlog is being spammed by the error from the filter.NET Framework ...Please see the error below:

Unable to get server variable 'HTTP_COOKIE'
The data area passed to a system call is too small.


Filename: .\helper.cpp
Line: 16
Function: void __cdecl Helper_T::GetServerVariable(struct _HTTP_FILTER_CONTEXT *,char *,char *,int *).

Would you know why this error is being thrown...I have a try catch around the e.Context.ServerVariables[ServerVariable.HTTP_COOKIE]; but this does not seem to stop the errors being written to the eventlog.

Your help would be greatly appreciated.

Regards

Paul

 

 

Sep 3, 2012 at 4:15 AM

Hi Paul,

I have encounterd the same problem, it appears that the problem is happening only on X86 Machines, 

since when i ran the same code on an X64 Machine, this error doesnt popup on the eventlog.

i reviewed this bug and it turnes out that the size is different, on X86 the BufferSize is 4Byte While on X64 its twise that size and thats why it 

the error doesnt exist there.

in order to Fix this you will need to fix the NativeCommands.cs and change the SF.MAXBUFFER from 0x400 to 0x800.

this will give you the same size of buffer as on 64Bit machines and on 64 bit you will have the max 4096 size. 

Hope this helps, 

Good luck 

Roei