diff options
| author | mrg <mrg@NetBSD.org> | 2018-11-21 10:25:17 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2018-11-21 10:25:17 +0000 |
| commit | be8012c759c2e2b4819348e2fa569a7d8a0018b7 (patch) | |
| tree | e2cf6d06b6731d3aa59f8bc065b965bb1d5abea8 /libexec | |
| parent | 45b13eee645ed49e3f250a715103ba64fd20b900 (diff) | |
two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate. now 10000 byte files say 10kB not 9kB.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/httpd/dir-index-bozo.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libexec/httpd/dir-index-bozo.c b/libexec/httpd/dir-index-bozo.c index 2e434662999..ad1ec1dbb4d 100644 --- a/libexec/httpd/dir-index-bozo.c +++ b/libexec/httpd/dir-index-bozo.c @@ -1,4 +1,4 @@ -/* $NetBSD: dir-index-bozo.c,v 1.26 2018/11/20 01:06:46 mrg Exp $ */ +/* $NetBSD: dir-index-bozo.c,v 1.27 2018/11/21 10:25:17 mrg Exp $ */ /* $eterna: dir-index-bozo.c,v 1.20 2011/11/18 09:21:15 mrg Exp $ */ @@ -157,7 +157,7 @@ bozo_dir_index(bozo_httpreq_t *request, const char *dirpath, int isindex) if (strcmp(name, "..") == 0) { bozo_printf(httpd, "<a href=\"../\">"); l += bozo_printf(httpd, "Parent Directory"); - } else if (S_ISDIR(sb.st_mode)) { + } else if (!nostat && S_ISDIR(sb.st_mode)) { bozo_printf(httpd, "<a href=\"%s/\">", urlname); l += bozo_printf(httpd, "%s/", htmlname); } else if (strchr(name, ':') != NULL) { @@ -185,6 +185,10 @@ bozo_dir_index(bozo_httpreq_t *request, const char *dirpath, int isindex) if (nostat) bozo_printf(httpd, "? ?"); else { + unsigned long long len; + + len = ((unsigned long long)sb.st_size + 1023) / 1024; + tm = gmtime(&sb.st_mtime); strftime(buf, sizeof buf, "%d-%b-%Y %R", tm); l += bozo_printf(httpd, "%s", buf); @@ -199,8 +203,7 @@ bozo_dir_index(bozo_httpreq_t *request, const char *dirpath, int isindex) spacebuf[i] = '\0'; bozo_printf(httpd, "%s", spacebuf); - bozo_printf(httpd, "%12llukB", - (unsigned long long)sb.st_size >> 10); + bozo_printf(httpd, "%12llukB", len); } bozo_printf(httpd, "\r\n"); } |
