Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/httpd two fixes reported by mouse:
details: https://anonhg.NetBSD.org/src/rev/d9f5a5ed9597
branches: trunk
changeset: 994772:d9f5a5ed9597
user: mrg <mrg%NetBSD.org@localhost>
date: Wed Nov 21 10:25:17 2018 +0000
description:
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:
libexec/httpd/dir-index-bozo.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diffs (39 lines):
diff -r bdb9aea5321b -r d9f5a5ed9597 libexec/httpd/dir-index-bozo.c
--- a/libexec/httpd/dir-index-bozo.c Wed Nov 21 09:49:39 2018 +0000
+++ b/libexec/httpd/dir-index-bozo.c Wed Nov 21 10:25:17 2018 +0000
@@ -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 @@
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 @@
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 @@
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");
}
Home |
Main Index |
Thread Index |
Old Index