Question : Internal Server Error

I have a C program executable. The executable is stored under the cgi-bin of the apache folder of the Solaris server.
/usr2/apache1.3.28/cgi-bin/nofax_vendret

When I call the program via the URL:
https://v02214.xxx.com/cgi-bini/nofax_vendret?udn=xhTc8689&key=c2f6yt7
I get the below error on the browser:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request....More information about this error may be available in the server error log."
The server error log has this info:
+++++++++++++++
[Thu Jun 24 00:57:40 2010] [error] [client 10.22.82.153] Premature end of script
 headers: /usr2/apache1.3.28/cgi-bin/nofax_vendret
+++++++++++++++

How do I know what is causing the internal service error? The error logs have no info.
Also no permission issue of the executable.

I can show error message on the screen if I type the URL:
https://v02214.xxx.com/cgi-bini/nofax_vendret?udn=xhTc8689&key=c2
It shows on the page:: Incomplete field: encoded_encrypted_deskey
(because of the strlen(encoded_encrypted_deskey) < 4 condition)

How can I output a value of the variable by the above print_error function that take a char* on its first argument? Like outputing the value of "user_name" variable.

print_error(user_name , 1);
The above gives the same Internal service error.


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/times.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <time.h>
#include <stdlib.h>
#include <lber.h>
#include <ldap.h>


int main()
{
.................

	/* Read standard input and put stuff into buffer */
	memset(buf,0,sizeof(buf));
	if (strcmp("POST",getenv("REQUEST_METHOD"))==0) scanf("%s",buf);
		else strcpy((char *)buf,getenv("QUERY_STRING"));


	/* Parse the input and separate all elements delimited by '&' */
	ptr1 = strtok(buf, "&");
	ptr2 = strtok(NULL, "&");

	/* UDN - 8 characters.  */
	ptr=strchr(ptr1,'=');
	strcpy(identifier, &ptr[1]);

	/* Check if field was filled */
	if (strlen(identifier) == 0) print_error("Incomplete field: UDN",1);

	/* Remove spaces and convert all percent sign notation */
	Remove_spaces(identifier, strlen(identifier));
	Check_percent(identifier, strlen(identifier));

	/* Key - 44 characters */
	ptr = strchr(ptr2, '=');
	strcpy(encoded_encrypted_deskey,&ptr[1]);

	Check_percent(encoded_encrypted_deskey, strlen(encoded_encrypted_deskey));

	/* Check to see if key is at least 4 characters long */
	if (strlen(encoded_encrypted_deskey) < 4) print_error("Incomplete field: encoded_encrypted_deskey",1);


	/* Recipient's name */
	strcpy(user_name, getenv("REMOTE_USER"));

....
	exit(0);
} /* End of main() */
+++++++++++++++++++++

Answer : Internal Server Error

other way;
try it on Environment.....you might explore a way for it.
1:
string special1 = System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
Random Solutions  
 
programming4us programming4us