I am trying to implement Pset6 but I'm having a huge problem with segmentation faults caused by strstr or strchr. The offending lines are
printf("OK %s\n", reqLine); tempStr = strstr(reqLine, "HTTP/1.1");
tempStr is a
char *. I did the printf just for my own observation and the terminal out put is
OK GET /cat.html HTTP/1.1 Segmentation fault (core dumped)
So reqLine isn't NULL. The segmentation fault always occurs here even if I search for some other string, for instant "/" instead of "HTTP/1.1". I use strstr elsewhere in my program in the exact same way and have no issues. I'm completely at a loss as to why this is happening. I have seen others have similar issues except they are making obvious mistakes such as not checking if the return value is NULL before going ahead and trying to use the result later on. I have no idea why this particular code snippet is failing.