For the php section, my sprintf is not working correctly to substitute the query string and is causing a "PHP Notice: Undefined index: name...". The path substitutes in just fine. It is rather baffling to me why this is happening because this was code that was provided, and by everything that I can see sprintf is being used correctly. Anyway, here's the code in question that does not work:
// open pipe to PHP interpreter
char* format = "QUERY_STRING=\"%s\" REDIRECT_STATUS=200 SCRIPT_FILENAME=\"%s\" php-cgi";
printf("query string: %s\n", query); //DEBUG
char command[strlen(format) + (strlen(path) - 2) + (strlen(query) - 2) + 1];
sprintf(command, format, query, path);
printf("command = %s\n",command); //DEBUG
query string: name=dog
command = QUERY_STRING="" REDIRECT_STATUS=200
PHP Notice: Undefined index: name in ....
If I hard-code the query string in the format string, it works just fine. Increasing the size of command doesn't help. Can anyone help me with this?