[Pkg-wmaker-commits] [wmix] 14/44: wmix: do not risk a crash (null-pointer-dereference) if $DISPLAY is not set

Doug Torrance dtorrance-guest at moszumanska.debian.org
Fri Sep 29 10:40:12 UTC 2017


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository wmix.

commit 17e39f525fbc867532c0ace62e4f61b8572daba7
Author: Christophe CURIS <christophe.curis at free.fr>
Date:   Sat Jun 7 21:21:42 2014 +0200

    wmix: do not risk a crash (null-pointer-dereference) if $DISPLAY is not set
    
    The original code merely assumed that an XOpenDisplay failure was caused
    only by incapacity to connect to the X server, but if $DISPLAY was not set
    then the fprintf would be given a NULL pointer which it may not appreciate
    (depending on the libc in use).
    Let's avoid that case and try to provide more info to help the user.
    
    Signed-off-by: Christophe CURIS <christophe.curis at free.fr>
---
 wmix.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/wmix.c b/wmix.c
index 5e31b5d..eed28b6 100644
--- a/wmix.c
+++ b/wmix.c
@@ -161,8 +161,20 @@ int main(int argc, char **argv)
     mixer_init(mixer_device, verbose, (const char **)exclude);
     mixer_set_channel(0);
 
-    if ((display = XOpenDisplay(display_name)) == NULL) {
-	fprintf(stderr, "Unable to open display \"%s\"\n", display_name);
+    display = XOpenDisplay(display_name);
+    if (display == NULL) {
+	const char *name;
+
+	if (display_name) {
+	    name = display_name;
+	} else {
+	    name = getenv("DISPLAY");
+	    if (name == NULL) {
+		fprintf(stderr, "wmix:error: Unable to open display, variable $DISPLAY not set\n");
+		return EXIT_FAILURE;
+	    }
+	}
+	fprintf(stderr, "wmix:error: Unable to open display \"%s\"\n", name);
 	return EXIT_FAILURE;
     }
     display_width = (float)DisplayWidth(display, DefaultScreen(display)) / 4.0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmix.git



More information about the Pkg-wmaker-commits mailing list