From 14e0372be8a015224b3126605810e14125a89a5c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 27 Sep 2026 22:04:57 +0300 Subject: ui-tree: Limit size of binary buffer hexdump Large binary files will generate an enormous page, which will be really slow to use --- ui-tree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui-tree.c b/ui-tree.c index 6a16c21..2447fec 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -65,12 +65,12 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) static void print_binary_buffer(char *buf, unsigned long size) { - unsigned long ofs, idx; + unsigned long ofs, idx, maxofs = 32768 /* up to 1 MiB */; static char ascii[ROWLEN + 1]; html("\n"); html(""); - for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { + for (ofs = 0; ofs < size && ofs < maxofs; ofs += ROWLEN, buf += ROWLEN) { htmlf("\n"); } + if (size > maxofs) + html("\n"); html("
ofshex dumpascii
%04lx", ofs); for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) htmlf("%*s%02x", @@ -83,6 +83,8 @@ static void print_binary_buffer(char *buf, unsigned long size) html_txt(ascii); html("
......
\n"); } -- cgit v1.3.1-23-gd82d