From 823665a3bdae1ba9f10f38e483e1b7b526ccf12e Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Tue, 21 Nov 2017 16:19:27 +0100 Subject: [PATCH] Sanitize negative urgency correctly --- src/notification.c | 5 ++++- src/notification.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/notification.c b/src/notification.c index 8c046c1..ad6beea 100644 --- a/src/notification.c +++ b/src/notification.c @@ -438,7 +438,10 @@ void notification_init(notification *n) n->dup_count = 0; /* urgency > URG_CRIT -> array out of range */ - n->urgency = n->urgency > URG_CRIT ? URG_CRIT : n->urgency; + if (n->urgency < URG_MIN) + n->urgency = URG_LOW; + if (n->urgency > URG_MAX) + n->urgency = URG_CRIT; if (!n->color_strings[ColFG]) { n->color_strings[ColFG] = xctx.color_strings[ColFG][n->urgency]; diff --git a/src/notification.h b/src/notification.h index df574ac..29b6c6c 100644 --- a/src/notification.h +++ b/src/notification.h @@ -11,9 +11,11 @@ enum urgency { URG_NONE = -1, + URG_MIN = 0, URG_LOW = 0, URG_NORM = 1, URG_CRIT = 2, + URG_MAX = 2, }; typedef struct _raw_image {