0

Hopefully this is the final problem with PSET6. I have completed all 4 functions and the program is running on the first try, meaning when I am visiting one of the pages, for example cat.jpg, the picture loads without any problem. However, when i am going back and I'm trying to visit another page, i.e. /index.html I am getting 404 error. Bellow i have the results from my terminal.

Using /home/ubuntu/workspace/pset6/public for server's root

Listening on port 8080

GET / HTTP/1.1

HTTP/1.1 200 OK

GET /test HTTP/1.1

HTTP/1.1 301 Moved Permanently

GET /test/ HTTP/1.1

HTTP/1.1 200 OK

GET /test/index.html HTTP/1.1

HTTP/1.1 200 OK

GET /favicon.ico HTTP/1.1

HTTP/1.1 404 Not Found

GET /cat.html HTTP/1.1

HTTP/1.1 404 Not Found

Using check50 i pass all but 3 tests:

:) Requesting test.js returns 200, text/javascript, and correct file

:) Requesting hello.php returns 200, text/html, and correct output

:( Requesting hello.php? returns 200, text/html, and correct output

\ expected output, not an exit code of 0

:( Requesting hello.php?name=Alice returns 200, text/html, and correct output

\ expected output, not an exit code of 0

:) Requesting /test redirects to /test/

:( Requesting /test/ outputs /test/index.html

:) Requesting directory containing index.php outputs index.php

Please let me know if anyone had a similar problem and what function was causing the program to crush or can point me to the right direction? Thanks in advance!

1

These kinds of problems occur if abs_path is not properly null terminated. You mention in an earlier post that you are using strncpy. From the man page for strncpy:

Warning: If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated.

You may be asking How could it work the first time? That's the magic of a buffer overflow. It depends on what's in memory. And subsequent calls to parse (not to mention everything else server does) change what's in memory and you get unpredicitble results.

| improve this answer | |
  • Thanks again! It worked! – dean.d Mar 15 '16 at 13:34

You must log in to answer this question.

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