Index: filed.c ================================================================== --- filed.c +++ filed.c @@ -557,27 +557,28 @@ /* Process an HTTP request and return the path requested */ static struct filed_http_request *filed_get_http_request(FILE *fp, struct filed_http_request *buffer_st) { char *method, *path; char *buffer, *workbuffer, *workbuffer_next; + char *fgets_ret; size_t buffer_len; off_t range_start, range_end, range_length; int range_request; - int fd; int i; - fd = fileno(fp); - range_start = 0; range_end = 0; range_request = 0; range_length = -1; buffer = buffer_st->tmpbuf; buffer_len = sizeof(buffer_st->tmpbuf); - fgets(buffer, buffer_len, fp); + fgets_ret = fgets(buffer, buffer_len, fp); + if (fgets_ret == NULL) { + return(NULL); + } method = buffer; buffer = strchr(buffer, ' '); if (buffer == NULL) { @@ -604,10 +605,13 @@ strcpy(buffer_st->path, path); for (i = 0; i < 100; i++) { buffer = buffer_st->tmpbuf; fgets(buffer, buffer_len, fp); + if (fgets_ret == NULL) { + break; + } if (strncasecmp(buffer, "Range: ", 7) == 0) { workbuffer = buffer + 7; if (strncasecmp(workbuffer, "bytes=", 6) == 0) { @@ -653,13 +657,10 @@ buffer_st->headers.range.present = range_request; buffer_st->headers.range.offset = range_start; buffer_st->headers.range.length = range_length; return(buffer_st); - - /* Make compiler happy */ - fd = fd; } /* Return an error page */ static void filed_error_page(FILE *fp, const char *date_current, int error_number) { char *error_string = "