| Summary: | Potential buffer overrun in SDL_GetWindowWMInfo() | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Frank <frank.praznik> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | daniel, icculus |
| Version: | 2.0.5 | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Attachments: | Testcase to show the overflow | ||
|
Description
Frank
2016-09-18 21:33:25 UTC
Created attachment 2758 [details] Testcase to show the overflow I just came across this bug when trying an app that was compiled with older SDL2 under Wayland (with a Wayland-enabled SDL2). Attached is a small testcase - running `sh sdlsyswminfo.c` under Wayland will trigger the assert. > Adding a size parameter SDL_GetWindowWMInfo() would address this but break binary compatibility in the process. A noninvasive method would be to replace the "int dummy" variable in the SDL_SysWMInfo union with something like "char dummy[64]" or some value which is at least as big as the largest window system struct so that it can't be too small, no matter how the header is configured. It wouldn't fix old software, but anything compiled against it going forward should be OK. Since this is and ABI break, SDL should also be changed to not write the info.wl.shell_surface member (or fail the SDL_GetWindowWMInfo() call entirely) unless the version member is at least as high as whatever SDL version is going to add the above padding. This would require apps that need the Wayland handles to be re-compiled against newer SDL, but would at least not break older apps that have optional X11 code but can otherwise run fine with Wayland-enabled SDL2. We'll run under the assumption that X11 is always available on Unix builds as a baseline, so you've got a C union with a pointer (Display *), and something that's pointer-sized (Window). In this configuration, the problem pieces are: - DirectFB (does this target even compile? There haven't been Ubuntu packages for it for years, if ever). - Wayland. Mir is rarely used, but fits in the same space as X11 in any case. Likewise for Vivante. Other platforms use more, but are generally the only target for those platforms, like UIKit on iOS. So I think your idea is good: we'll pad the union to 64 bytes (8 64-bit pointers), and have wayland and directfb fail if not passed a version of at least 2.0.6 (which will definitely have this fix). I think that'll be Good Enough. --ryan. Fixed in https://hg.libsdl.org/SDL/rev/69452f9839d5, thanks! --ryan. |