All other checks pass except this one:

:( Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0

I have no idea how to fix it, here is part of my Parse function that handles path and query:

//storing absolute path
if (strchr(path, '?')) {
    char* absPath;
    char* myQuery;

    absPath = strtok(path, "?");
    myQuery = strtok(NULL, "?");

    strcpy(abs_path, absPath);
    strcpy(query, myQuery);
} else {
    strcpy(abs_path, path);
    query[0] = '\0';

1 Answer 1


This \ expected output, not an exit code of 0 is a seg fault. For testing, you would need to request /hello.php? with a curl request instead of a browser. Browsers (firefox and opera in my testing) drop the trailing '?'.

The seg fault occurs here strcpy(query, myQuery); when myQuery is NULL. The second argument to strcpy is a const char * and NULL isn't. (I believe it is technically a void *).

The problem stems from here myQuery = strtok(NULL, "?");; when there are no query parameters, it will return NULL.

  • Thank you so much! Just used an if statement to check if it was NULL and it worked :-)
    – Omar
    Aug 7, 2016 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .