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
556
557
558
559
560
561

562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578



579
580
581
582
583
584
585
	return(buffer);
}

/* 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;

	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);




	method = buffer;

	buffer = strchr(buffer, ' ');
	if (buffer == NULL) {
		return(NULL);
	}







>



<


<
<








|
>
>
>







555
556
557
558
559
560
561
562
563
564
565

566
567


568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
	return(buffer);
}

/* 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 i;



	range_start = 0;
	range_end   = 0;
	range_request = 0;
	range_length = -1;

	buffer = buffer_st->tmpbuf;
	buffer_len = sizeof(buffer_st->tmpbuf);

	fgets_ret = fgets(buffer, buffer_len, fp);
	if (fgets_ret == NULL) {
		return(NULL);
	}

	method = buffer;

	buffer = strchr(buffer, ' ');
	if (buffer == NULL) {
		return(NULL);
	}
602
603
604
605
606
607
608



609
610
611
612
613
614
615

	/* Note path */
	strcpy(buffer_st->path, path);

	for (i = 0; i < 100; i++) {
		buffer = buffer_st->tmpbuf;
		fgets(buffer, buffer_len, fp);




		if (strncasecmp(buffer, "Range: ", 7) == 0) {
			workbuffer = buffer + 7;

			if (strncasecmp(workbuffer, "bytes=", 6) == 0) {
				workbuffer += 6;








>
>
>







603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619

	/* Note path */
	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) {
				workbuffer += 6;

651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667

	/* Fill up structure to return */
	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 = "<html><head><title>ERROR</title></head><body>Unable to process request</body></html>";

	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",







<
<
<







655
656
657
658
659
660
661



662
663
664
665
666
667
668

	/* Fill up structure to return */
	buffer_st->headers.range.present = range_request;
	buffer_st->headers.range.offset  = range_start;
	buffer_st->headers.range.length  = range_length;

	return(buffer_st);



}

/* Return an error page */
static void filed_error_page(FILE *fp, const char *date_current, int error_number) {
	char *error_string = "<html><head><title>ERROR</title></head><body>Unable to process request</body></html>";

	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",