solusipse/fiche — pull request #2 by hmage (2013-09-17 17:33:10+00:00)
Title: Fix segfaults

On debian 7.0, sending anything to fiche results in segfault.

hmage@dofire:~/fiche$ make
gcc -o fiche -pthread -O2 fiche.c
hmage@dofire:~/fiche$ ./fiche -o /var/www/code/ -d code.hmage.net
====================================
Domain name: http://code.hmage.net/
Saving files to: /var/www/code/
Fiche started listening on port 9999.
====================================
Tue Sep 17 17:20:59 2013
Client: 95.31.136.165 (95-31-136-165.broadband.corbina.ru)
Segmentation fault

Further investigation shows that buffers weren't allocated big enough to contain null-byte at the end of the string, so strlen() and other string functions can go beyond the size of allocated buffer and they do in my case, triggering memory protection error.