Comment 24 for bug 61746

Revision history for this message
In , Bram Verweij (amverweij) wrote :

Created an attachment (id=7553)
new patch that fixes real problem

Take another look at lnx_acpi.c, starting from line 61. In the event of the
crash, the string that should be parsed is "video VID 00000080 00000000".

The old code tries to chop off "video" with a call to strtok(ev, "video") on
line 68, and then goes on to parse the rest of the string. This is not what
happens: the call to strtok sees "v","i","d","e", and "o" as delimiters, and
puts the first non-empty string (i.e., " VID 0000080 00000000") into the
variable video. The remainder of the string is then empty; the subsequent calls
to strtok(NULL, " ") return NULL. When such a NULL is passed to strtoul, we
have our well-known crash.

This new patch changes the initial call to strtok to indeed just chop off the
"video" bit by using a space as delimiter. This leaves the rest for parsing
into GFX, notify and data. This seems to be what was intended, enabling the
debug code in there also puts the right lines into my Xorg.0.log.

I've removed the zero-pointer checks from my earlier patch; even though this is
making assumptions about the format that is being read; i.e., all video events
should read "video <string1> <string2> <string3>". I don't have the specs but
it seems that this assumption is valid.