mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-20 14:00:03 +01:00
Fix overflow checking extension versions
The easiest way to check for the version of an extension is to send the maximum
possible version numbers in the QueryVersion request. The X server overflows on
these as it assumes you will send a reasonable version number.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit 548fc937b2)
This commit is contained in:
parent
416ea95d80
commit
2ceb44827f
1 changed files with 11 additions and 7 deletions
|
|
@ -259,15 +259,19 @@ extern void FormatDouble(double dbl, char *string);
|
||||||
* or a value greater than 0
|
* or a value greater than 0
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int
|
||||||
version_compare(uint16_t a_major, uint16_t a_minor,
|
version_compare(uint32_t a_major, uint32_t a_minor,
|
||||||
uint16_t b_major, uint16_t b_minor)
|
uint32_t b_major, uint32_t b_minor)
|
||||||
{
|
{
|
||||||
int a, b;
|
if (a_major > b_major)
|
||||||
|
return 1;
|
||||||
|
if (a_major < b_major)
|
||||||
|
return -1;
|
||||||
|
if (a_minor > b_minor)
|
||||||
|
return 1;
|
||||||
|
if (a_minor < b_minor)
|
||||||
|
return -1;
|
||||||
|
|
||||||
a = a_major << 16 | a_minor;
|
return 0;
|
||||||
b = b_major << 16 | b_minor;
|
|
||||||
|
|
||||||
return (a - b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* some macros to help swap requests, replies, and events */
|
/* some macros to help swap requests, replies, and events */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue