-
-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix buffer overflow on X11 error bug #1748
Fix buffer overflow on X11 error bug #1748
Conversation
Skip descendant checking if cursor over desktop in query_x11_window_at_pos. Simplify and correct check for whether cursor is over conky. Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
✅ Deploy Preview for conkyweb canceled.
|
@@ -258,7 +258,7 @@ static int x11_error_handler(Display *d, XErrorEvent *err) { | |||
const char *minor = xcb_errors_get_name_for_minor_code( | |||
xcb_errors_ctx, err->request_code, err->minor_code); | |||
if (minor != nullptr) { | |||
const std::size_t size = strlen(base_name) + strlen(extension) + 4; | |||
const std::size_t size = strlen(major) + strlen(minor) + 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After stepping through the code with gdb, this is what was causing the crash. Not sure why it's snprintf
fails over code_description
being too small (isn't that the point of snprintf - to truncate?).
Another call to
The one I already fixed in this PR was the one I could figure out quickly (and prevent a crash locally). The second one (called because user didn't have XDB errors installed), I can't force to cause a crash:
After digging deeper into implementation of if (code_description == nullptr) {
const std::size_t size = 37;
code_description = new char[size];
snprintf(code_description, size, "error code: [major: %i, minor: %i]",
err->request_code, err->minor_code);
code_allocated = true;
} because
is "target buffer length", and it's equal to 1, while Which leaves the following options:
|
Closes #1739.
Additional changes