commit 47eaa0e007e02fd3af48c398d5409c303562b15c from: Omar Polo date: Sun Jun 09 21:13:14 2024 UTC pagebundler: always append a NUL byte, don't emit full length Even if we have the full length for the about:* pages, we just treat them as C strings. Except that they don't have a NUL terminator. Add it so we can continue to prented they're strings. commit - a646688fe1198fdb2ff1cb6e30ea2e06aa981c13 commit + 47eaa0e007e02fd3af48c398d5409c303562b15c blob - 002fad4712cf4c8c2ac3c6039cd5e6ee63e726d3 blob + 49e10ea66c67584f7e03967da8788545e4f98cf4 --- fs.c +++ fs.c @@ -181,15 +181,14 @@ fs_load_url(struct tab *tab, const char *url) const char *name; const char *path; const uint8_t *data; - size_t len; } pages[] = { - {"about", NULL, about_about, about_about_len}, - {"blank", NULL, about_blank, about_blank_len}, - {"bookmarks", bpath, bookmarks, bookmarks_len}, - {"crash", NULL, about_crash, about_crash_len}, - {"help", NULL, about_help, about_help_len}, - {"license", NULL, about_license, about_license_len}, - {"new", NULL, about_new, about_new_len}, + {"about", NULL, about_about}, + {"blank", NULL, about_blank}, + {"bookmarks", bpath, bookmarks}, + {"crash", NULL, about_crash}, + {"help", NULL, about_help}, + {"license", NULL, about_license}, + {"new", NULL, about_new}, }, *page = NULL; if (!strncmp(url, "about:", 6)) { blob - 9693e7f732a802f9b62b98490a72382c7c3ef4e7 blob + 4c565f6d3bbe6a3b0faac9881d2b2be0ebdd0775 --- pagebundler.c +++ pagebundler.c @@ -64,8 +64,7 @@ validc(int c) int main(int argc, char **argv) { - size_t len, r, i, n; - int did; + size_t r, i, n; FILE *f; uint8_t buf[BUFSIZ]; char varname[PATH_MAX]; @@ -85,16 +84,10 @@ main(int argc, char **argv) printf("const uint8_t %s[] = {", varname); - did = 0; - len = 0; n = 0; for (;;) { r = fread(buf, 1, sizeof(buf), f); - len += r; - if (r != 0) - did = 1; - for (i = 0; i < r; ++i, ++n) { if (n % 12 == 0) printf("\n\t"); @@ -114,21 +107,9 @@ main(int argc, char **argv) break; } - if (!did) { - /* - * if nothing was emitted, add a NUL byte. This was - * still produce an exact copy of the file because - * `len' doesn't count this NUL byte. It prevents the - * "use of GNU empty initializer extension" warning - * when bundling pages/about_empty.gmi - */ - printf("\t0x0\n"); - } - + printf("\t0x0\n"); printf("}; /* %s */\n", varname); - printf("size_t %s_len = %zu;\n", varname, len); - fclose(f); return 0; }