0

My check50 version 1 gives all :) but version 2 gives this result

:) server.c exists
:) server compiles
:( Requesting cat.jpg returns 200, image/jpeg, and correct image
:) Requesting cat.html returns 200, text/html, and correct file
:) Requesting cat2.HTML returns 200, text/html, and correct file
:) Requesting cat3.HtMl returns 200, text/html, and correct file
:( Requesting cat.gif returns 200, image/gif, and correct file
:) Requesting favicon.ico returns 200, image/x-icon, and correct file
:) Requesting test.css returns 200, text/css, and correct file
:) 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
   \ expected output, but not "HTTP/1.1 403 Forbidden\r\nContent-Type:..."
:( Requesting two files in a row (cat.html then cat.jpg) succeeds

although when I am running ./server public it is showing error 403 Forbidden everytime. Please help me, I will post the code link if you want. Thanks in advance.

EDIT : code deleted as per the rules

5
  • 1
    \ expected output, not an exit code of 0 from check50 is a seg fault. Are you using fseek or ftell in your load function? In that case see this – DinoCoderSaurus Jul 6 '16 at 16:16
  • Thanks, Well I am not using either of them, I am implementing using realloc method. Please see my edit, I have uploaded my load function – Salil Jain Jul 6 '16 at 17:39
  • 1
    Ok. The seg fault is probably coming from parse when there is a query, based on those two failures from check50. The 403 could be a real 403, ie permissions problem, or some problem in indexes. Did you make any changes to distro code (reviewed your last 403 post, but it's a little difficult to follow)? – DinoCoderSaurus Jul 6 '16 at 17:58
  • Thanks. I did not made any change to distro code. I don't think there is any permission problem because someone suggested me to change permissions to which I executed this sudo chmod 777 ~/workspace/pset6/public maybe the problem is in parse only. Please have a look at my code [pastebin.com/MMHqP1WE]. In my last 403 post I wanted to say that the 403 error is called by access function under transfer function which I checked using printf. – Salil Jain Jul 7 '16 at 7:00
  • I think the link is not working. Please see my edit – Salil Jain Jul 7 '16 at 10:16
1

INDEXES

:( Requesting /test/ outputs /test/index.html
:( Requesting> directory containing index.php outputs index.php
\ expected> output, but not "HTTP/1.1 403 Forbidden\r\nContent-Type:..."

(And all your 403 problems)

According to man access:

RETURN VALUE
On success (all requested permissions granted, or mode is F_OK and the file exists), zero is returned. On error (at least one bit in mode asked for a permission that is denied, or mode is F_OK and the file does not exist, or some other error occurred), -1 is returned, and errno is set appropriately.

This test ( Requesting /test/ outputs /test/index.html fails because:

[the first] if(access(temp,F_OK)) returns 0. As a boolean, 0 is false, so program proceeds.

[the second] if(access(temp,F_OK)) returns -1. As a boolean, -1 is true. So temp, which has the value /index.php is returned. There is no /index.php => 403 (from somewhere in main).

You should follow the index.php test and see that you will get the same, wrong, result.

My advice: access() returns an int. Treat it like an int. (You don't have to take my word for it; review all the places access() is used in the distro code).

PARSE

:( 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

The exit code of 0 usually indicates a seg fault. You need to use gdb to debug this. Tips here to start it up. After you start gdb in a terminal window with a breakpoint set at parse (it's just sitting there waiting for a request), open another terminal session. Execute a curl request, something like curl -i http://localhost:8080/hello.html?name=x. Now back in the gdb terminal, it will be waiting for you to step through parse. This if(line[i]=='?') might be a good place to set another breakpoint.

With patience and perseverance, gdb will help you get a perfect pset6.

7
  • Thanks, that access thing was my mistake after modifying, those two errors are gone also there is no error 403.But I am not able to use curl command. can you tell me where to use it I mean directly on terminal or first starting the server and then writing it? – Salil Jain Jul 7 '16 at 17:15
  • 1
    There is a good guide on how to use curl in the pset directions. Just search for curl. Basically, you need two terminal windows gdb with server in the first, then your curl requests in the second. Practice with the instructions ( ie no gdb, staff server) and you will get the hang of it. – DinoCoderSaurus Jul 7 '16 at 17:23
  • Okay i will try it – Salil Jain Jul 7 '16 at 17:24
  • Thanks man, I am almost done only 3 :( in cat.jpg one, cat.gif one and requesting two files in a row. I think their is a problem related to \r\n because I have never used them in my code. Can you tell me do we have to use "\r\n"or is their some other problem? thanks – Salil Jain Jul 8 '16 at 8:33
  • 1
    It is here for(char c=fgetc(file);c!=EOF;c=fgetc(file)) in load. You cannot use char, info here (the load section) – DinoCoderSaurus Jul 8 '16 at 12:19

You must log in to answer this question.

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