FreeBSD Bugzilla – Attachment 16145 Details for
Bug 29725
[picobsd] [patch] fixed segmentation fault in simple_httpd and some other bugfixes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 3.86 KB, created by
Eugene Grosbein
on 2001-08-15 11:10:17 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Eugene Grosbein
Created:
2001-08-15 11:10:17 UTC
Size:
3.86 KB
patch
obsolete
>diff -u -r1.1.1.1 -r1.9 >--- simple_httpd.c 2001/08/15 04:09:38 1.1.1.1 >+++ simple_httpd.c 2001/08/15 09:32:34 1.9 >@@ -47,6 +47,8 @@ > #include <time.h> > #include <unistd.h> > >+#include "mime_t.h" >+ > int http_port = 80; > int daemonize = 1; > int verbose = 0; >@@ -99,7 +101,7 @@ > perror("bind socket"); > exit(1); > } >- if (verbose) printf("simple_httpd\n",http_port); >+ if (verbose) printf("simple_httpd:%d\n",http_port); > } > > /* >@@ -191,14 +193,15 @@ > */ > http_request() > { >- int fd, lg, ld, i; >+ int fd, lg, /*ld,*/ i; > int cmd = 0; >- int http1 = 0; >+/* int http1 = 0; */ > char *p, *par; > char *filename, *c; >+ size_t fname_len; > struct stat file_status; > char req[1024]; >- char msg[1024]; >+/* char msg[1024]; */ > char buff[8192]; > > lg = read(con_sock, req, 1024); >@@ -231,10 +234,13 @@ > > c = strtok(NULL, " "); > if (fetch_mode[0] != NULL) strcpy(filename,fetch_mode); >- if (filename == NULL || >- strlen(filename)==1) filename="/index.html"; >+ fname_len=strlen(filename); >+ if (filename == NULL || fname_len == 1) { >+ filename="/index.html"; >+ fname_len=11; >+ } > >- while (filename[0]== '/') filename++; >+ while (filename[0]== '/') { filename++; fname_len--; } > > /* CGI handling. Untested */ > if (!strncmp(filename,"cgi-bin/",8)) >@@ -243,6 +249,7 @@ > if (par=strstr(filename,"?")) > { > *par=0; >+/* fname_len=par-filename; // not used but note to the future */ > par++; > } > if (access(filename,X_OK)) goto conti; >@@ -309,23 +316,22 @@ > http_output(httpd_server_ident); > http_date(); > >- sprintf(buff, "Content-length: %d\r\n", file_status.st_size); >- >- if (strstr(filename,".txt")) { >- strcpy(buff,"Content-type: text/plain\r\n"); >- } else if (strstr(filename,".html") || strstr(filename,".htm")) { >- strcpy(buff,"Content-type: text/html\r\n"); >- } else if (strstr(filename,".gif")) { >- strcpy(buff,"Content-type: image/gif\r\n"); >- } else if (strstr(filename,".jpg")) { >- strcpy(buff,"Content-type: image/jpeg\r\n"); >- } else { >- /* Take a guess at content if we don't have something already */ >- strcpy(buff,"Content-type: "); >- strcat(buff,strstr(filename,".")+1); >- strcat(buff,"\r\n"); >- } >+ sprintf(buff, "Content-length: %lld\r\n", file_status.st_size); > write(con_sock, buff, strlen(buff)); >+ >+ strcpy(buff,"Content-type: "); >+ i=-1; >+ if (strchr(filename,'.')) >+ for (i=mime_type_max; i>=0; i--) /* file has an extention */ >+ if ((c=strstr(filename,mime_type[i][0]))) >+ if (filename+fname_len==c+strlen(mime_type[i][0])) { >+ strcat(buff,mime_type[i][1]); >+ break; >+ } >+ >+ if (i<0) /* extention is unknown */ >+ strcat(buff,default_mime_type); /* or file has no extention */ >+ http_output(buff); > > strftime(buff, 50, "Last-Modified: %a, %d %h %Y %H:%M:%S %Z\r\n\r\n", >gmtime(&file_status.st_mtime)); > write(con_sock, buff, strlen(buff)); >@@ -351,8 +357,8 @@ > { > extern char *optarg; > extern int optind; >- int bflag, ch, fd, ld; >- int lg; >+ int /*bflag,*/ ch, /*fd,*/ ld; >+/* int lg; */ > int httpd_group = 65534; > pid_t server_pid;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 29725
: 16145