int urldecode(char *src, char *last, char *dest)

G

gert

free() is defined to do nothing, if you pass a null
pointer to it. The problem is because when you go
and write data to this null pointer, anything could
happen.

#include <fcgi_stdio.h>
#include <stdlib.h>

int post(){
char *input;
char *lenstr;
long len;
lenstr=getenv("CONTENT_LENGTH");
len=-1;
if (lenstr != NULL) sscanf(lenstr,"%ld",&len);
input = malloc(len+1);
if (input != NULL) fgets(input, len+1, stdin);
printf("Content-Type: text/xml; charset=utf-8"
"\r\n"
"\r\n"
"<xml>%s</xml>"
"\n",input);
free(input);
return 0;
}

int main (void){
while (FCGI_Accept() >= 0) { post(); }
return 0;
}

Changed the code a bit so it will always post back generated output no
matter what happens.

PS It doesn't look that more difficult compared to php or python :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top