- bail out if screen resolution does not match PPM dimensions.
Previously a 640x480 PPM on an e.g. 720x400 console would just segfault when reading the lines. While this bug should perhaps be fixed to handle such cases properly we just exit gracefully until somebody is willing to take care of it properly.
This commit is contained in:
parent
8dcb33c3eb
commit
7307e06122
@ -257,7 +257,9 @@ static void fb_drawimage(void)
|
|||||||
|
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
free(head);
|
free(head);
|
||||||
|
if (width != G.scr_var.xres || height != G.scr_var.yres)
|
||||||
|
bb_error_msg_and_die("PPM %dx%d does not match screen %dx%d",
|
||||||
|
width, height, G.scr_var.xres, G.scr_var.yres);
|
||||||
line_size = width*3;
|
line_size = width*3;
|
||||||
if (width > G.scr_var.xres)
|
if (width > G.scr_var.xres)
|
||||||
width = G.scr_var.xres;
|
width = G.scr_var.xres;
|
||||||
|
@ -30,7 +30,8 @@ enum {
|
|||||||
/* CMD_XCOMPAT = 10, */
|
/* CMD_XCOMPAT = 10, */
|
||||||
CMD_ALL = 11,
|
CMD_ALL = 11,
|
||||||
CMD_INFO = 12,
|
CMD_INFO = 12,
|
||||||
CMD_CHANGE = 13,
|
CMD_SHOW = 13,
|
||||||
|
CMD_CHANGE = 14,
|
||||||
|
|
||||||
#if ENABLE_FEATURE_FBSET_FANCY
|
#if ENABLE_FEATURE_FBSET_FANCY
|
||||||
CMD_XRES = 100,
|
CMD_XRES = 100,
|
||||||
@ -123,7 +124,8 @@ static const struct cmdoptions_t {
|
|||||||
{ "vsync" , 1, CMD_VSYNC },
|
{ "vsync" , 1, CMD_VSYNC },
|
||||||
{ "laced" , 1, CMD_LACED },
|
{ "laced" , 1, CMD_LACED },
|
||||||
{ "double" , 1, CMD_DOUBLE },
|
{ "double" , 1, CMD_DOUBLE },
|
||||||
{ "n" , 0, CMD_CHANGE },
|
{ "show" , 0, CMD_SHOW },
|
||||||
|
{ "s" , 0, CMD_SHOW },
|
||||||
#if ENABLE_FEATURE_FBSET_FANCY
|
#if ENABLE_FEATURE_FBSET_FANCY
|
||||||
{ "all" , 0, CMD_ALL },
|
{ "all" , 0, CMD_ALL },
|
||||||
{ "xres" , 1, CMD_XRES },
|
{ "xres" , 1, CMD_XRES },
|
||||||
@ -172,7 +174,7 @@ static void ss(uint32_t *x, uint32_t flag, char *buf, const char *what)
|
|||||||
*x |= flag;
|
*x |= flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int readmode(struct fb_var_screeninfo *base, const char *fn,
|
static int read_mode_db(struct fb_var_screeninfo *base, const char *fn,
|
||||||
const char *mode)
|
const char *mode)
|
||||||
{
|
{
|
||||||
char *token[2], *p, *s;
|
char *token[2], *p, *s;
|
||||||
@ -302,7 +304,7 @@ int fbset_main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
OPT_CHANGE = (1 << 0),
|
OPT_CHANGE = (1 << 0),
|
||||||
/*OPT_INFO = (1 << 1), ??*/
|
OPT_SHOW = (1 << 1),
|
||||||
OPT_READMODE = (1 << 2),
|
OPT_READMODE = (1 << 2),
|
||||||
OPT_ALL = (1 << 9),
|
OPT_ALL = (1 << 9),
|
||||||
};
|
};
|
||||||
@ -333,6 +335,12 @@ int fbset_main(int argc, char **argv)
|
|||||||
case CMD_DB:
|
case CMD_DB:
|
||||||
modefile = argv[1];
|
modefile = argv[1];
|
||||||
break;
|
break;
|
||||||
|
case CMD_ALL:
|
||||||
|
options |= OPT_ALL;
|
||||||
|
break;
|
||||||
|
case CMD_SHOW:
|
||||||
|
options |= OPT_SHOW;
|
||||||
|
break;
|
||||||
case CMD_GEOMETRY:
|
case CMD_GEOMETRY:
|
||||||
varset.xres = xatou32(argv[1]);
|
varset.xres = xatou32(argv[1]);
|
||||||
varset.yres = xatou32(argv[2]);
|
varset.yres = xatou32(argv[2]);
|
||||||
@ -349,12 +357,6 @@ int fbset_main(int argc, char **argv)
|
|||||||
varset.hsync_len = xatou32(argv[6]);
|
varset.hsync_len = xatou32(argv[6]);
|
||||||
varset.vsync_len = xatou32(argv[7]);
|
varset.vsync_len = xatou32(argv[7]);
|
||||||
break;
|
break;
|
||||||
case CMD_ALL:
|
|
||||||
options |= OPT_ALL;
|
|
||||||
break;
|
|
||||||
case CMD_CHANGE:
|
|
||||||
options |= OPT_CHANGE;
|
|
||||||
break;
|
|
||||||
#if ENABLE_FEATURE_FBSET_FANCY
|
#if ENABLE_FEATURE_FBSET_FANCY
|
||||||
case CMD_XRES:
|
case CMD_XRES:
|
||||||
varset.xres = xatou32(argv[1]);
|
varset.xres = xatou32(argv[1]);
|
||||||
@ -367,6 +369,15 @@ int fbset_main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
switch (g_cmdoptions[i].code) {
|
||||||
|
case CMD_FB:
|
||||||
|
case CMD_DB:
|
||||||
|
case CMD_ALL:
|
||||||
|
case CMD_SHOW:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
options |= OPT_CHANGE; /* the other commands imply changes */
|
||||||
|
}
|
||||||
argc -= g_cmdoptions[i].param_count;
|
argc -= g_cmdoptions[i].param_count;
|
||||||
argv += g_cmdoptions[i].param_count;
|
argv += g_cmdoptions[i].param_count;
|
||||||
goto contin;
|
goto contin;
|
||||||
@ -384,18 +395,19 @@ int fbset_main(int argc, char **argv)
|
|||||||
#if !ENABLE_FEATURE_FBSET_READMODE
|
#if !ENABLE_FEATURE_FBSET_READMODE
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
#else
|
#else
|
||||||
if (!readmode(&var, modefile, mode)) {
|
if (!read_mode_db(&var, modefile, mode)) {
|
||||||
bb_error_msg_and_die("unknown video mode '%s'", mode);
|
bb_error_msg_and_die("unknown video mode '%s'", mode);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
setmode(&var, &varset);
|
|
||||||
if (options & OPT_CHANGE) {
|
if (options & OPT_CHANGE) {
|
||||||
|
setmode(&var, &varset);
|
||||||
if (options & OPT_ALL)
|
if (options & OPT_ALL)
|
||||||
var.activate = FB_ACTIVATE_ALL;
|
var.activate = FB_ACTIVATE_ALL;
|
||||||
xioctl(fh, FBIOPUT_VSCREENINFO, &var);
|
xioctl(fh, FBIOPUT_VSCREENINFO, &var);
|
||||||
}
|
}
|
||||||
|
if (options == 0 || options & OPT_SHOW)
|
||||||
showmode(&var);
|
showmode(&var);
|
||||||
/* Don't close the file, as exiting will take care of that */
|
/* Don't close the file, as exiting will take care of that */
|
||||||
/* close(fh); */
|
/* close(fh); */
|
||||||
|
Loading…
Reference in New Issue
Block a user