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.
Aaron Marcher me@drkhsh.at
Fri, 11 Aug 2017 14:33:02 +0200
1 files changed,
5 insertions(+),
2 deletions(-)
jump to
M
slstatus.c
→
slstatus.c
@@ -380,10 +380,9 @@
static const char * keyboard_indicators(void) { - Display *dpy = XOpenDisplay(NULL); XKeyboardState state; + XGetKeyboardControl(dpy, &state); - XCloseDisplay(dpy); switch (state.led_mask) { case 1:@@ -879,6 +878,10 @@ sigaction(SIGTERM, &act, 0);
if (!sflag) { dpy = XOpenDisplay(NULL); + if (!dpy) { + fprintf(stderr, "slstatus: cannot open display"); + exit(1); + } } setlocale(LC_ALL, "");