X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;ds=sidebyside;f=file.c;h=c8833b6a55b4f3023cae4c7cb3e6cb98a7de71c8;hb=b9178b9357798ae23a5724333cc6572d14f23958;hp=055035eb7f715cd636918c2be75738c8338cb818;hpb=528bbddafebf6d48e6d0dc29d1e2c8263ce6deb7;p=project%2Fuhttpd.git diff --git a/file.c b/file.c index 055035e..c8833b6 100644 --- a/file.c +++ b/file.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -287,10 +288,8 @@ static const char * uh_file_mime_lookup(const char *path) static const char * uh_file_mktag(struct stat *s, char *buf, int len) { - snprintf(buf, len, "\"%x-%x-%x\"", - (unsigned int) s->st_ino, - (unsigned int) s->st_size, - (unsigned int) s->st_mtime); + snprintf(buf, len, "\"%" PRIx64 "-%" PRIx64 "-%" PRIx64 "\"", + s->st_ino, s->st_size, (uint64_t)s->st_mtime); return buf; } @@ -479,11 +478,11 @@ static void list_entries(struct client *cl, struct dirent **files, int count, bool dir = !!(files[i]->d_type & DT_DIR); if (name[0] == '.' && name[1] == 0) - continue; + goto next; sprintf(file, "%s", name); if (stat(local_path, &s)) - continue; + goto next; if (!dir) { suffix = ""; @@ -492,7 +491,7 @@ static void list_entries(struct client *cl, struct dirent **files, int count, } if (!(s.st_mode & mode)) - continue; + goto next; uh_chunk_printf(cl, "
  • %s%s" @@ -505,6 +504,7 @@ static void list_entries(struct client *cl, struct dirent **files, int count, type, s.st_size / 1024.0); *file = 0; +next: free(files[i]); } } @@ -567,7 +567,6 @@ static void uh_file_data(struct client *cl, struct path_info *pi, int fd) !uh_file_if_range(cl, &pi->stat) || !uh_file_if_unmodified_since(cl, &pi->stat) || !uh_file_if_none_match(cl, &pi->stat)) { - ustream_printf(cl->us, "Content-Length: 0\r\n"); ustream_printf(cl->us, "\r\n"); uh_request_done(cl); close(fd); @@ -580,7 +579,7 @@ static void uh_file_data(struct client *cl, struct path_info *pi, int fd) ustream_printf(cl->us, "Content-Type: %s\r\n", uh_file_mime_lookup(pi->name)); - ustream_printf(cl->us, "Content-Length: %i\r\n\r\n", + ustream_printf(cl->us, "Content-Length: %" PRIu64 "\r\n\r\n", pi->stat.st_size);