From 259ce08f81eaaaa087b6b1994fce7dde81820c52 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 22 Feb 2015 23:51:27 +0000 Subject: [PATCH] Fix segfault in HTTP handler. dump1090 crashes when a non-existent file with no dot in its name is requested. strrchr() will return NULL, not an empty string, when there is no match. --- net_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net_io.c b/net_io.c index a979883f5..52eaddc0e 100644 --- a/net_io.c +++ b/net_io.c @@ -796,7 +796,7 @@ int handleHTTPRequest(struct client *c, char *p) { snprintf(ctype, sizeof ctype, MODES_CONTENT_TYPE_HTML); // Default content type ext = strrchr(getFile, '.'); - if (strlen(ext) > 0) { + if (ext) { if (strstr(ext, ".json")) { snprintf(ctype, sizeof ctype, MODES_CONTENT_TYPE_JSON); } else if (strstr(ext, ".css")) {