Check-in [74c7ab003e]
Overview
Comment:Updated to check fgets() return value and removed now unused variable
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:74c7ab003e4d2aa1fdae244ea76f9e31a00920e9
User & Date: rkeene on 2014-02-11 05:49:04
Other Links: manifest | tags
Context
2014-02-11
05:52
Updated to actually set fgets_ret, oops check-in: 299fa6a68f user: rkeene tags: trunk
05:49
Updated to check fgets() return value and removed now unused variable check-in: 74c7ab003e user: rkeene tags: trunk
05:15
Post release version increment check-in: 6f539a8f16 user: rkeene tags: trunk
Changes

Modified filed.c from [3d68b06497] to [602946c512].

   555    555   	return(buffer);
   556    556   }
   557    557   
   558    558   /* Process an HTTP request and return the path requested */
   559    559   static struct filed_http_request *filed_get_http_request(FILE *fp, struct filed_http_request *buffer_st) {
   560    560   	char *method, *path;
   561    561   	char *buffer, *workbuffer, *workbuffer_next;
          562  +	char *fgets_ret;
   562    563   	size_t buffer_len;
   563    564   	off_t range_start, range_end, range_length;
   564    565   	int range_request;
   565         -	int fd;
   566    566   	int i;
   567    567   
   568         -	fd = fileno(fp);
   569         -
   570    568   	range_start = 0;
   571    569   	range_end   = 0;
   572    570   	range_request = 0;
   573    571   	range_length = -1;
   574    572   
   575    573   	buffer = buffer_st->tmpbuf;
   576    574   	buffer_len = sizeof(buffer_st->tmpbuf);
   577    575   
   578         -	fgets(buffer, buffer_len, fp);
          576  +	fgets_ret = fgets(buffer, buffer_len, fp);
          577  +	if (fgets_ret == NULL) {
          578  +		return(NULL);
          579  +	}
   579    580   
   580    581   	method = buffer;
   581    582   
   582    583   	buffer = strchr(buffer, ' ');
   583    584   	if (buffer == NULL) {
   584    585   		return(NULL);
   585    586   	}
................................................................................
   602    603   
   603    604   	/* Note path */
   604    605   	strcpy(buffer_st->path, path);
   605    606   
   606    607   	for (i = 0; i < 100; i++) {
   607    608   		buffer = buffer_st->tmpbuf;
   608    609   		fgets(buffer, buffer_len, fp);
          610  +		if (fgets_ret == NULL) {
          611  +			break;
          612  +		}
   609    613   
   610    614   		if (strncasecmp(buffer, "Range: ", 7) == 0) {
   611    615   			workbuffer = buffer + 7;
   612    616   
   613    617   			if (strncasecmp(workbuffer, "bytes=", 6) == 0) {
   614    618   				workbuffer += 6;
   615    619   
................................................................................
   651    655   
   652    656   	/* Fill up structure to return */
   653    657   	buffer_st->headers.range.present = range_request;
   654    658   	buffer_st->headers.range.offset  = range_start;
   655    659   	buffer_st->headers.range.length  = range_length;
   656    660   
   657    661   	return(buffer_st);
   658         -
   659         -	/* Make compiler happy */
   660         -	fd = fd;
   661    662   }
   662    663   
   663    664   /* Return an error page */
   664    665   static void filed_error_page(FILE *fp, const char *date_current, int error_number) {
   665    666   	char *error_string = "<html><head><title>ERROR</title></head><body>Unable to process request</body></html>";
   666    667   
   667    668   	fprintf(fp, "HTTP/1.1 %i Not OK\r\nDate: %s\r\nServer: filed\r\nLast-Modified: %s\r\nContent-Length: %llu\r\nContent-Type: %s\r\nConnection: close\r\n\r\n%s",