[SDL] [SDL 1.3][PATCH] Fix usage of invalid file descriptor
ntlucas at gmail.com
Wed Sep 28 18:22:22 PDT 2011
On Wed, Sep 28, 2011 at 17:54, Marr <wm33 at att.net> wrote:
> On Tuesday 27 September 2011 21:00:31 Nuno Lucas wrote:
>> while the second patch just adds a check for the open() result and
>> ignores the device if it fails.
> Hi Nuno (and anyone with code check-in privilege),
> Even though I'm not running 64-bit Linux and am not using SDL 1.3, I took a
> look at your 2nd patch and the 'abs' line caught my eye.
> By sheer coincidence, I had just posted a bugfix for a problem in the SDL
> 1.2.14 joystick property detection code which I suspected was related to the
> 'abs definition that I noticed in your patch. Here's my post:
> On further investigation, I found that the SDL 1.3 (Aug 05 2011 snapshot, aka
> SDL1.3.0-5605) X11 "touch" interface code has the _exact_ _same_ _bug_. In
> essence, it only allocates 5 elements for the 'ioctl(.., EVIOCGABS(..), ..)'
> call, which actually returns 6 elements, as defined in '/usr/linux/input.h'
> (Slackware 13.1):
After seeing the "quality" of the "touch/joystick" patch this doesn't
surprise me at all.
Besides the blatantly wrong indentation, all the code seems a huge
hack, without any regard for good programming practices.
If it was me, I would revert the whole patch until properly reviewed,
as I'm sure more bugs are waiting silently.
For one, I don't understand why the direct open of Linux input events
when X is already running. That should be a X job. It should only be
necessary when X is not running, like with the fbdev driver (or
possibly with a new wayland driver).
I don't know nothing about joysticks, but at least for touch events
there is no reason no not use the X input subsystem.
> A couple of closing notes: (1) For anyone unaware, there is no "touch"
> interface code in SDL 1.2.x, so Nuno's patches and my addendum fix is not
> applicable there. (2) Given this repeated problem with inadequate allocation
> for the EVIOCGABS ioctl, I took a look through all of the 1.2.14 and
> 1.3.0-5605 SDL source code and, fortunately, the Linux joystick and X11
> "touch" code are the only areas affected.
> Bill Marr
More information about the SDL