|
Line 0
Link Here
|
| 0 |
- |
1 |
/* |
|
|
2 |
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice (including the next |
| 12 |
* paragraph) shall be included in all copies or substantial portions of the |
| 13 |
* Software. |
| 14 |
* |
| 15 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 |
* DEALINGS IN THE SOFTWARE. |
| 22 |
*/ |
| 23 |
#ifdef HAVE_CONFIG_H |
| 24 |
# include "config.h" |
| 25 |
#endif |
| 26 |
|
| 27 |
#include "xhiv.h" |
| 28 |
#include <X11/Xlib.h> |
| 29 |
#include <X11/Xlibint.h> |
| 30 |
#include "xhiv-Xrandr.h" |
| 31 |
#include <assert.h> |
| 32 |
#include <stdio.h> |
| 33 |
#include <limits.h> |
| 34 |
|
| 35 |
static void |
| 36 |
testOverflowFields(void) |
| 37 |
{ |
| 38 |
const xQueryExtensionReply overflow_xrandr_qext_reply = { |
| 39 |
.type = X_Reply, |
| 40 |
.length = 0, |
| 41 |
.present = xTrue, |
| 42 |
.major_opcode = MY_XRANDR_EXT_CODE, |
| 43 |
.first_event = 255, /* Only events < 128 are allowed in protocol */ |
| 44 |
.first_error = 255 |
| 45 |
}; |
| 46 |
Display *dpy, *saved_dpy; |
| 47 |
int major = MY_XRANDR_MAJOR_VERSION; |
| 48 |
int minor = MY_XRANDR_MINOR_VERSION; |
| 49 |
int status; |
| 50 |
|
| 51 |
xrandr_qext_response.response_data = &overflow_xrandr_qext_reply; |
| 52 |
|
| 53 |
dpy = XhivOpenDisplay(&xrandr_vers_response); |
| 54 |
saved_dpy = calloc(1, sizeof(Display)); |
| 55 |
assert(saved_dpy != NULL); |
| 56 |
memcpy(saved_dpy, dpy, sizeof(Display)); |
| 57 |
|
| 58 |
printf("XRRQueryVersion: overflow event id test\n"); |
| 59 |
status = XRRQueryVersion(dpy, &major, &minor); |
| 60 |
assert(status != 0); |
| 61 |
/* check that event_vec didn't overflow into wire_vec */ |
| 62 |
for (int i = 0 ; i < 127; i++) { |
| 63 |
assert(dpy->wire_vec[i] == saved_dpy->wire_vec[i]); |
| 64 |
} |
| 65 |
/* check that wire_vec didn't overflow into following field */ |
| 66 |
assert(dpy->lock_meaning == saved_dpy->lock_meaning); |
| 67 |
|
| 68 |
XhivCloseDisplay(dpy); |
| 69 |
} |
| 70 |
|
| 71 |
int |
| 72 |
main(int argc, char **argv) |
| 73 |
{ |
| 74 |
testOverflowFields(); |
| 75 |
printf("XRRQueryVersion: all tests passed\n"); |
| 76 |
return 0; |
| 77 |
} |