Fixed major bug: drivers that accepted size arguments could wind

up with more than 80 characters (20x4) in their display, and thus
overwrite memory outside of the allocated 80 characterwframebuffer.

For example, using a 20x6 screen would do this.

All drivers now either ignore a missing framebuffer, or allocate it
themselves - the latter is prefered.
This commit is contained in:
ddouthitt
2001-09-27 23:46:55 +00:00
parent 71c3035611
commit 74153173c1
9 changed files with 16 additions and 57 deletions
-5
View File
@@ -187,11 +187,6 @@ CFontz_init (lcd_logical_driver * driver, char *args)
CFontz_autoscroll (0);
CFontz_backlight (backlight_brightness);
if (!driver->framebuf) {
syslog(LOG_ERR, "cfontz_init: no frame buffer!");
CFontz_close ();
return -1;
}
// Set the functions the driver supports...
driver->clear = CFontz_clear;
-6
View File
@@ -361,12 +361,6 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
MtxOrb_cursorblink (DEFAULT_CURSORBLINK);
MtxOrb_contrast (contrast);
if (!driver->framebuf) {
syslog(LOG_ERR, "no frame buffer! exiting driver init...");
MtxOrb_close ();
return -1;
}
/*
* Configure the display functions
*/
-7
View File
@@ -26,13 +26,6 @@ debug_init (struct lcd_logical_driver *driver, char *args)
debug_drv = driver;
if (driver->framebuf)
syslog(LOG_INFO, "frame buffer at: %010X", (int) driver->framebuf);
else {
syslog(LOG_ERR, "no frame buffer!");
return -1;
}
debug_clear ();
driver->daemonize = 0;
-9
View File
@@ -196,15 +196,6 @@ int LB216_init(lcd_logical_driver *driver, char *args)
LB216_hidecursor();
LB216_backlight(backlight_brightness);
if(!driver->framebuf)
{
fprintf(stderr, "LB216_init: No frame buffer.\n");
driver->close();
return -1;
}
// Set the functions the driver supports...
driver->clear = LB216_clear;
+8 -10
View File
@@ -445,18 +445,16 @@ lcd_add_driver (char *driver, char *args)
// Default settings for the driver...
lcd_drv_init(add, NULL);
memset(buf, '\0', sizeof(buf));
add->framebuf = buf; // *** HACK: makes drivers think framebuffer is allocated!
i = init_driver (add, args);
// Allocate space for a framebuffer... *AFTER* the driver
// has a chance to initialize height and width!!
if ((add->framebuf = malloc (add->wid * add->hgt)) == NULL) {
snprintf (buf, sizeof(buf), "couldn't allocate framebuffer for driver \"%s\"", driver);
syslog (LOG_ERR, buf);
// free (add);
return -1;
if (!add->framebuf) {
if ((add->framebuf = malloc (add->wid * add->hgt)) == NULL) {
snprintf (buf, sizeof(buf), "couldn't allocate framebuffer of %d chars for driver \"%s\"",
(add->wid * add->hgt), driver);
syslog (LOG_ERR, buf);
// free (add);
return -1;
}
}
memset (add->framebuf, ' ', (add->wid * add->hgt));
+6 -6
View File
@@ -217,12 +217,16 @@ sed1520_init (struct lcd_logical_driver *driver, char *args)
writecommand (0xAF, CS1 + CS2);
writecommand (0xC0, CS1 + CS2);
selectpage (3);
driver->cellwid = 6;
driver->cellhgt = 8;
// The Framebuffer LCDproc allocates by default is too small,
// so we free() it and allocate one of adequate size.
// so we free() it (if it exists) and allocate one of adequate size.
if (!driver->framebuf)
free (driver->framebuf);
driver->framebuf = malloc (488);
driver->framebuf = malloc (122 * 4);
if (!driver->framebuf)
{
sed1520_close ();
@@ -232,10 +236,6 @@ sed1520_init (struct lcd_logical_driver *driver, char *args)
// clear screen
memset (driver->framebuf, 0, 122 * 4);
driver->cellwid = 6;
driver->cellhgt = 8; // FIXME: sed1520->cellwid always stays 5
// regardless what it is set to here. This is
// a bug but not inside this driver.
driver->clear = sed1520_clear;
driver->string = sed1520_string;
driver->chr = sed1520_chr;
+2 -3
View File
@@ -447,9 +447,8 @@ stv5730_init (struct lcd_logical_driver *driver, char *args)
memset (driver->framebuf, 0, STV5730_WID * STV5730_HGT);
driver->cellwid = 4;
driver->cellhgt = 6; // FIXME: stv5730->cellwid always stays 5
// regardless what it is set to here. This is
// a bug but not inside this driver.
driver->cellhgt = 6;
driver->clear = stv5730_clear;
driver->string = stv5730_string;
driver->chr = stv5730_chr;
-6
View File
@@ -38,12 +38,6 @@ text_init (lcd_logical_driver * driver, char *args)
{
text = driver;
if (!text->framebuf) {
syslog(LOG_ERR, "text: no frame buffer!");
text_close ();
return -1;
}
text->wid = LCD_DEFAULT_WIDTH;
text->hgt = LCD_DEFAULT_HEIGHT;
text->cellwid = LCD_DEFAULT_CELL_WIDTH;
-5
View File
@@ -148,11 +148,6 @@ sli_init (lcd_logical_driver * driver, char *args)
out[1] = 0x001; /* Clear LCD, not sure if this belongs here */
write (fd, out, 2);
if (!driver->framebuf) {
fprintf (stderr, "sli_init: No frame buffer.\n");
sli_close ();
return -1;
}
// Set LCD parameters (I use a 16x2 LCD) -- small but still useful
// Its also much cheaper than the higher quality Matrix Orbital modules
// Currently, $30 for interface kit and 16x2 non-backlit LCD...