r/cprogramming • u/FuTuReFrIcK42069 • Oct 07 '26
HTTP Server my first complete-ish C project
https://github.com/abdouyouyou/Basic-http-server/tree/mainHello everyone, It's been several years since i last wrote some C, and i always for the life of me wanted to write an HTTP server in C, and now it's been like 1 year since i finished university so i said what the hell why not do it, so after reading beej's guide i tried to write a very basic http server.
I wanted to share the work with the community, and would welcome thoughts.
We had written code in C ofc for two years, however it was mostly exercises on diffrent data structures aswell as problem solving.
We wrote a CRUD system in C using binary files but never scratched that itch.
And as the years went by in Uni, C slowly faded out of use for me but i always wanted to visit it back so here i am.
I wanted to share the absolute joy it was to get the desired results, i forgot how fun C can be, it always felt like the souls like of programming languages, but always was the most understandable as it was the closest to the machine, to be frank i encourage people to make similar projects especially to get the cobweb off lol.
View all comments
Show parent comment
2
u/Zirias_FreeBSD Oct 08 '26 edited Oct 09 '26
It's not just that. You have the next potential buffer overflow directly below with the
strcat. You don't do anything I would call "parsing", which could be okayish for a lab project, but such likely exploitable overflows really must be avoided (and that's not even too hard, you might even just use strtok for a first draft).Other stuff I can immediately spot:
accessto check whether the file exists, but the result of the laterfopenis not checked. If the file vanished in between, you get a null pointer dereference. Correct way is to ditchaccessand just try to open, if that fails, error out with not found./../../../../../../../../../../../etc/shadow.