1
0
Fork 0

Fixed possible NULL-deref and removed unnecessary XOpenDisplay()

- Added a check for the return value of XOpenDisplay() in main().
  This fixes a possible NULL-deref.
- Removed unnsecessary XOpenDisplay and XCloseDisplay from
  keyboard_indicators(). The ones in main() are sufficent.
This commit is contained in:
Aaron Marcher 2017-08-11 14:33:02 +02:00
parent 1814061396
commit 6f01174392
No known key found for this signature in database
GPG key ID: 74B048E5C2474F9A

View file

@ -380,10 +380,9 @@ kernel_release(void)
static const char * static const char *
keyboard_indicators(void) keyboard_indicators(void)
{ {
Display *dpy = XOpenDisplay(NULL);
XKeyboardState state; XKeyboardState state;
XGetKeyboardControl(dpy, &state); XGetKeyboardControl(dpy, &state);
XCloseDisplay(dpy);
switch (state.led_mask) { switch (state.led_mask) {
case 1: case 1:
@ -879,6 +878,10 @@ main(int argc, char *argv[])
if (!sflag) { if (!sflag) {
dpy = XOpenDisplay(NULL); dpy = XOpenDisplay(NULL);
if (!dpy) {
fprintf(stderr, "slstatus: cannot open display");
exit(1);
}
} }
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");