So I've been working on server.c and I have the the lookup, parse, and indexes function finished. With index passing back "index.php", "index.html", or NULL.
It runs through that but when it gets to the htmlspecialchars function (implemented by the staff) the program gets to the line marked here and returns 1.
char* htmlspecialchars(const char* s)
{
// ensure s is not NULL
if (s == NULL)
{
return NULL;
}
// allocate enough space for an unescaped copy of s
char* t = malloc(strlen(s) + 1); // crashes and returns 1
if (t == NULL)
{
return NULL;
}
t[0] = '\0';
...
}
Not sure what's up and why it has problems processing the information. At the point it crashes my local variables are as follows:
s = 0x6175a3 ".."
t = 0x4013f0 <_start> "1\355I\211\321^H\211\342H\203\344\360PTI\307\300 <@"
There are no other local variables in use, s is a const char* and t is a char*.
In my indexes function I did use strdup(path) to copy the value from the value passed into the indexes function along with strcat() to create the proper strings for the return value.
Any idea why this might be happening or how I can resolve it?