Do not panic if the splash screen is bigger than the framebuffer

This fixes a kernel crash if the splash screen does not fit inside the
framebuffer. It should probably be truncated (and optionally centered)
instead, but this avoids a panic in the meantime.

Tested on NetBSD/amd64 with a vesa framebuffer.

From Christian Koch (cfkoch@) of EdgeBSD; thanks!

XXX pull-up(s)
This commit is contained in:
khorben 2016-04-25 22:26:50 +00:00
parent 505ea9765f
commit 30e30cd09c

View File

@ -1,4 +1,4 @@
/* $NetBSD: splash.c,v 1.12 2012/06/02 14:24:00 martin Exp $ */
/* $NetBSD: splash.c,v 1.13 2016/04/25 22:26:50 khorben Exp $ */
/*-
* Copyright (c) 2006 Jared D. McNeill <jmcneill@invisible.ca>
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: splash.c,v 1.12 2012/06/02 14:24:00 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: splash.c,v 1.13 2016/04/25 22:26:50 khorben Exp $");
#include "opt_splash.h"
@ -195,6 +195,14 @@ splash_render(struct splash_info *si, int flg)
aprint_debug("%s: splash loaded, width %d height %d comp %d\n",
__func__, width, height, comp);
if ((width > si->si_width) || (height > si->si_height)) {
aprint_error(
"WARNING: splash size (%dx%d) too big for framebuffer (%dx%d)\n",
width, height, si->si_width, si->si_height);
stbi_image_free(data);
return EINVAL;
}
/* XXX */
if (flg & SPLASH_F_CENTER) {
xoff = (si->si_width - width) / 2;