[PATCH] loadfont: accept fonts up to 64 KiB in size

Denys Vlasenko vda.linux at googlemail.com
Thu Nov 3 19:59:15 UTC 2016


Fixed in git, thanks!

On Tue, Oct 25, 2016 at 6:15 AM, Alex Henrie <alexhenrie24 at gmail.com> wrote:
> Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
> ---
> Hello,
>
> The ArchWiki currently implies that users with HiDPI screens should set
> a mkinitcpio hook to set the console font to latarcyrheb-sun32 in early
> userspace.[1-4] However, this does not actually work because
> latarcyrheb-sun32 is 34,377 bytes long when decompressed. Instead of
> getting a new font, the user gets the cryptic error "setfont: input
> file: bad length".[5]
>
> A PSF font could in theory be even larger than 64 KiB because of an
> enormous Unicode map,[6] but in practice 64 KiB is a very safe limit.
>
> [1] https://wiki.archlinux.org/index.php/HiDPI#Linux_console
> [2] https://wiki.archlinux.org/index.php/Fonts#Console_fonts
> [3] https://wiki.archlinux.org/index.php/Mkinitcpio#HOOKS
> [4] https://wiki.archlinux.org/index.php/Mkinitcpio#Common_hooks
> [5] https://bugs.archlinux.org/task/19109#comment102571
> [6] https://www.win.tue.nl/~aeb/linux/kbd/font-formats-1.html
>
> Please consider this simple fix for a very frustrating bug.
>
> -Alex
>
> console-tools/loadfont.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
> index 032506d..bb536f1 100644
> --- a/console-tools/loadfont.c
> +++ b/console-tools/loadfont.c
> @@ -75,6 +75,8 @@ struct psf1_header {
>    && (x)->magic[1] == PSF1_MAGIC1 \
>  )
>
> +#define MAX_PSF_LEN 65536
> +
>  #if ENABLE_FEATURE_LOADFONT_PSF2
>  enum {
>         PSF2_MAGIC0 = 0x72,
> @@ -320,7 +322,7 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
>          * with stat(); now that we accept compressed files,
>          * just read the entire file.
>          */
> -       len = 32*1024; // can't be larger
> +       len = MAX_PSF_LEN;
>         buffer = xmalloc_read(STDIN_FILENO, &len);
>         // xmalloc_open_zipped_read_close(filename, &len);
>         if (!buffer)
> @@ -405,7 +407,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
>                 }
>         }
>         // load font
> -       len = 32*1024; // can't be larger
> +       len = MAX_PSF_LEN;
>         buffer = xmalloc_open_zipped_read_close(*argv, &len);
>         if (!buffer)
>                 bb_simple_perror_msg_and_die(*argv);
> --
> 2.10.1
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list