diff options
| Commit | 14e0372be8a015224b3126605810e14125a89a5c (patch) | |
|---|---|---|
| Author | 2026-09-27 22:04:57 +0300 | |
| Committer | 2026-09-27 22:14:38 +0300 | |
| Files | 9bb9985d30c33fee9222ce97f6cbebf2e676d374 | |
| cgit-14e0372be8a015224b3126605810e14125a89a5c.tar cgit-14e0372be8a015224b3126605810e14125a89a5c.tar.gz cgit-14e0372be8a015224b3126605810e14125a89a5c.zip | ||
| Parent | 47f1595e49218f016179aab2e39207fe203da54a (diff) | |
ui-tree: Limit size of binary buffer hexdump
Large binary files will generate an enormous page, which will be really
slow to use
1 files changed, 4 insertions, 2 deletions
| -rw-r--r-- | ui-tree.c | 6 |
@@ -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("<table summary='blob content' class='bin-blob'>\n"); html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); - for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { + for (ofs = 0; ofs < size && ofs < maxofs; ofs += ROWLEN, buf += ROWLEN) { htmlf("<tr><td class='right'>%04lx</td><td class='hex'>", 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("</td></tr>\n"); } + if (size > maxofs) + html("<tr><td>...</td><td>...</td><td></td></tr>\n"); html("</table>\n"); } |
