3 Commits

5 changed files with 11 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ compile:
compile-debian:
@mkdir -p bin
gcc $(LIBS) -o bin/libnecronda-server.so --shared -fPIC $(CFLAGS) $(INCLUDE) \
$(DEBIAN_OPTS)
$(DEBIAN_OPTS) -O3
gcc src/necronda-server.c -o bin/necronda-server $(CFLAGS) $(INCLUDE) \
-Lbin -lnecronda-server -Wl,-rpath=$(shell pwd)/bin \
$(DEBIAN_OPTS)
$(DEBIAN_OPTS) -O3

View File

@@ -219,6 +219,10 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int
goto respond;
}
if (strncmp(uri.req_path, "/.well-known/", 13) == 0) {
http_add_header_field(&res.hdr, "Access-Control-Allow-Origin", "*");
}
if (strncmp(uri.req_path, "/.well-known/", 13) != 0 && strstr(uri.path, "/.") != NULL) {
res.status = http_get_status(403);
sprintf(err_msg, "Parts of this URI are hidden.");

View File

@@ -291,11 +291,11 @@ int cache_update_entry(int entry_num, const char *filename, const char *webroot)
const char *type = magic_file(magic, filename);
char type_new[24];
sprintf(type_new, "%s", type);
if (strcmp(type, "text/plain") == 0) {
if (strncmp(type, "text/", 5) == 0) {
if (strcmp(filename + strlen(filename) - 4, ".css") == 0) {
sprintf(type_new, "text/css");
} else if (strcmp(filename + strlen(filename) - 3, ".js") == 0) {
sprintf(type_new, "text/javascript");
sprintf(type_new, "application/javascript");
}
}
strcpy(cache[entry_num].meta.type, type_new);

View File

@@ -65,13 +65,13 @@ typedef struct {
typedef struct {
char method[16];
char *uri;
char version[3];
char version[4];
http_hdr hdr;
} http_req;
typedef struct {
const http_status *status;
char version[3];
char version[4];
http_hdr hdr;
} http_res;

View File

@@ -106,7 +106,7 @@ int url_decode(const char *str, char *dec, long *size) {
int mime_is_compressible(const char *type) {
if (type == NULL) return 0;
char type_parsed[64];
strncpy(type_parsed, type, sizeof(type_parsed));
strncpy(type_parsed, type, sizeof(type_parsed) - 1);
char *pos = strchr(type_parsed, ';');
if (pos != NULL) pos[0] = 0;
return