As stated, everything appears to work as it should when my server is running. The first check50 passes completely, but the second one fails on the following:

:( Requesting favicon.ico returns 200, image/x-icon, and correct file
:( Requesting /test/ outputs /test/index.html
:( Requesting directory containing index.php outputs index.php
\ expected output, not an exit code of 0

I believe it may have something to do with my indexes function, which I will link to below. Any guidance is much appreciated.

(link removed)


How many bytes have you allocated to pathcopy? How many bytes are you trying to stuff in it? (Ditto pathcopy2). Once you fix that, make sure newpath is sized properly.

Also here's more trouble your way:

char* newpath = malloc(sizeof(pathcopy)); You say: give me a char pointer to a chunk of memory the size of pathcopy (which, by the way, isn't really enough, because of the char* secret sauce)

newpath = pathcopy; Here you say, oh never mind, point me to the memory that pathcopy owns. As you did with pathcopy earlier in the function, you have to populate the contents of newpath.

Some observations you might consider to make your code smaller and more elegant (and smaller means less to debug :)

  1. strcpy and strcat will take a string literal, so strcat(something,"index.php") will accomplish the same thing as declaring a variable and setting it to "index.php". That'd save some lines of code and some memory.

  2. if you made your pathcopy a string (char* allocated to an appropriate size) instead of a char array, you could eliminate the need for newptr.

  3. Since the program is an either/or, consider using one variable instead of two for your "searchpath" result.

Since the other tests pass server2, your load and parse functions are probably ok. Examine your lookup function for a typo or a missing block to troubleshoot the favicon.ico error.

  • Hi @Dino, I've updated my pathcopies to: char pathcopy[strlen(path)+11] to account for the addition of the appended string. I've also malloc'd my newpaths as follows: char* newpath = malloc((strlen(path)+11) * sizeof(char)). Still getting the same output from check50. What am I missing? – klmo8 Apr 14 '16 at 15:58
  • strlen(path)? take it for a spin in gdb..... – DinoCoderSaurus Apr 14 '16 at 16:26
  • Sorry to not get the hint, but I still don't understand what the problem is here; strlen(path) gives me the # of chars contained in path, and then I tack on enough room for the chars to be appended on. I suppose I could just allocate a static amount of memory for these variables, but that seems to create new problems... – klmo8 Apr 14 '16 at 17:05
  • Answer edited. Sorry, I didn't give you all the info you needed the first time around. – DinoCoderSaurus Apr 14 '16 at 19:29
  • That is very helpful, thank you! Now, my server is fully functional and I've resolved two of the check50 errors but am still failing on: :( Requesting /test/ outputs /test/index.html. Any idea what might be causing this? I see that the path loses its "index.html" as soon as it breaks out of the indexes function--that doesn't seem right. – klmo8 Apr 14 '16 at 20:48

You must log in to answer this question.

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