Subversion Repositories Tewi

Rev

Rev 212 | Rev 215 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 212 Rev 213
Line 1... Line 1...
1
/* $Id: http.c 212 2024-10-02 17:44:55Z nishi $ */
1
/* $Id: http.c 213 2024-10-02 17:45:40Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 80... Line 80...
80
	nl = 0;
80
	nl = 0;
81
 
81
 
82
	while(1) {
82
	while(1) {
83
		int i;
83
		int i;
84
		int len;
84
		int len;
85
			int n;
85
		int n;
86
#ifndef USE_POLL
86
#ifndef USE_POLL
87
		struct timeval tv;
87
		struct timeval tv;
88
		FD_ZERO(&fds);
88
		FD_ZERO(&fds);
89
		FD_SET(sock, &fds);
89
		FD_SET(sock, &fds);
90
		tv.tv_sec = 5;
90
		tv.tv_sec = 5;
Line 341... Line 341...
341
				free(tmp);
341
				free(tmp);
342
			}
342
			}
343
		}
343
		}
344
		free(req->path);
344
		free(req->path);
345
		req->path = result;
345
		req->path = result;
346
	
346
 
347
		incr = 0;
347
		incr = 0;
348
		p = malloc(1);
348
		p = malloc(1);
349
		p[0] = 0;
349
		p[0] = 0;
350
		for(j = 0;; j++) {
350
		for(j = 0;; j++) {
351
			if(req->path[j] == '/' || req->path[j] == 0) {
351
			if(req->path[j] == '/' || req->path[j] == 0) {
352
				char oldc = req->path[j];
352
				char oldc = req->path[j];
353
				char* pth;
353
				char* pth;
354
				cbuf[0] = oldc;
354
				cbuf[0] = oldc;
355
				req->path[j] = 0;
355
				req->path[j] = 0;
356
	
356
 
357
				pth = req->path + incr;
357
				pth = req->path + incr;
358
	
358
 
359
				if(strcmp(pth, "..") == 0) {
359
				if(strcmp(pth, "..") == 0) {
360
					int k;
360
					int k;
361
					if(p[strlen(p) - 1] == '/') p[strlen(p) - 1] = 0;
361
					if(p[strlen(p) - 1] == '/') p[strlen(p) - 1] = 0;
362
					for(k = strlen(p) - 1; k >= 0; k--) {
362
					for(k = strlen(p) - 1; k >= 0; k--) {
363
						if(p[k] == '/') {
363
						if(p[k] == '/') {
Line 373... Line 373...
373
				} else {
373
				} else {
374
					char* tmp = p;
374
					char* tmp = p;
375
					p = cm_strcat3(tmp, pth, cbuf);
375
					p = cm_strcat3(tmp, pth, cbuf);
376
					free(tmp);
376
					free(tmp);
377
				}
377
				}
378
	
378
 
379
				incr = j + 1;
379
				incr = j + 1;
380
				if(oldc == 0) break;
380
				if(oldc == 0) break;
381
			}
381
			}
382
		}
382
		}
383
		free(req->path);
383
		free(req->path);