From ec246e2a513f4a5b031b4c50df632a1e223a8d6c Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Sat, 15 Jan 2011 16:06:31 +1100 Subject: [PATCH] Avoid infinite loop (and quiet gcc warning) --- darkhttpd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/darkhttpd.c b/darkhttpd.c index 9c406df..10e0397 100644 --- a/darkhttpd.c +++ b/darkhttpd.c @@ -832,12 +832,12 @@ static const char *uri_content_type(const char *uri) { size_t period, urilen = strlen(uri); - for (period=urilen-1; - period > 0 && - uri[period] != '.' && - (urilen-period-1) <= longest_ext; - period--) - ; + period=urilen; + while ((period > 0) && + (uri[period] != '.') && + ((urilen-period-1) <= longest_ext)) { + period--; + } if (uri[period] == '.') {