cloudhead / node-static

rfc 2616 compliant HTTP static-file server module, with built-in caching.
MIT License
2.17k stars 245 forks source link

Protect fs.stat calls from invalid path arguments #223

Closed brpvieira closed 3 years ago

brpvieira commented 3 years ago

In node versions > 10 fs.stat throws invalid path errors synchronously, this crashes node-static as described here. Wrapping the fs.stat call in try .. catch block allows node-static to gracefully respond to the bad request with a 404.