Index: main/http.c =================================================================== --- main/http.c (revision 382781) +++ main/http.c (working copy) @@ -230,7 +230,7 @@ goto out403; } - /* Disallow any funny filenames at all */ + /* Disallow any funny filenames at all (checking first character only??) */ if ((uri[0] < 33) || strchr("./|~@#$%^&*() \t", uri[0])) { goto out403; } @@ -245,6 +245,7 @@ if (!(mtype = ast_http_ftype2mtype(ftype))) { snprintf(wkspace, sizeof(wkspace), "text/%s", S_OR(ftype, "plain")); + mtype = wkspace; } /* Cap maximum length */ @@ -262,12 +263,12 @@ goto out404; } - fd = open(path, O_RDONLY); - if (fd < 0) { + if (strstr(path, "/private/") && !astman_is_authed(ast_http_manid_from_vars(headers))) { goto out403; } - if (strstr(path, "/private/") && !astman_is_authed(ast_http_manid_from_vars(headers))) { + fd = open(path, O_RDONLY); + if (fd < 0) { goto out403; } @@ -290,6 +291,7 @@ } if ( (http_header = ast_str_create(255)) == NULL) { + close(fd); return -1; }