[PATCH] elographics divide-by-zero crasher
Daniel Drake
ddrake at brontes3d.com
Mon Mar 12 12:17:36 PDT 2007
A bad configuration can result in height or width being zero. This potentially
causes a divide-by-zero error in xf86EloConvert().
Detect the bad configuration early on and produce a meaningful error message.
More details at:
https://bugs.freedesktop.org/show_bug.cgi?id=9803
Index: xf86-input-elographics-1.1.0/src/xf86Elo.c
===================================================================
--- xf86-input-elographics-1.1.0.orig/src/xf86Elo.c
+++ xf86-input-elographics-1.1.0/src/xf86Elo.c
@@ -1689,6 +1689,7 @@ xf86EloInit(InputDriverPtr drv,
EloPrivatePtr priv=NULL;
char *str;
int portrait = 0;
+ int height, width;
local = xf86EloAllocate(drv);
if (!local) {
@@ -1755,11 +1756,21 @@ xf86EloInit(InputDriverPtr drv,
str = "Landscape";
}
xf86Msg(X_CONFIG, "Elographics device will work in %s mode\n", str);
-
- if (priv->max_x - priv->min_x <= 0) {
+
+ width = priv->max_x - priv->min_x;
+ height = priv->max_y - priv->min_y;
+ if (width == 0) {
+ xf86Msg(X_ERROR, "Elographics: Cannot configure touchscreen with width 0\n");
+ return local;
+ }
+ else if (width < 0) {
xf86Msg(X_INFO, "Elographics: reverse x mode (minimum x position >= maximum x position)\n");
- }
- if (priv->max_y - priv->min_y <= 0) {
+ }
+ if (height == 0) {
+ xf86Msg(X_ERROR, "Elographics: Cannot configure touchscreen with height 0\n");
+ return local;
+ }
+ else if (height < 0) {
xf86Msg(X_INFO, "Elographics: reverse y mode (minimum y position >= maximum y position)\n");
}
More information about the xorg
mailing list