Validate closing reasons inside dbus method
Also fixes a nice off by one error. According to notification spec, the reason 0 doesn't exist, while the undefined reason wouldn't have been sent.
This commit is contained in:
parent
744712ad77
commit
20807a09b0
@ -324,6 +324,12 @@ static void on_get_server_information(GDBusConnection *connection,
|
||||
|
||||
void notification_closed(notification *n, enum reason reason)
|
||||
{
|
||||
if (reason < REASON_MIN || REASON_MAX < reason) {
|
||||
fprintf(stderr, "ERROR: Closing notification with reason '%d' not supported. "
|
||||
"Closing it with reason '%d'.\n", reason, REASON_UNDEF);
|
||||
reason = REASON_UNDEF;
|
||||
}
|
||||
|
||||
if (!dbus_conn) {
|
||||
fprintf(stderr, "ERROR: Tried to close notification but dbus connection not set!\n");
|
||||
return;
|
||||
|
@ -6,10 +6,12 @@
|
||||
#include "notification.h"
|
||||
|
||||
enum reason {
|
||||
REASON_MIN = 1,
|
||||
REASON_TIME = 1,
|
||||
REASON_USER = 2,
|
||||
REASON_SIG = 3,
|
||||
REASON_UNDEF = 4,
|
||||
REASON_MAX = 4,
|
||||
};
|
||||
|
||||
int initdbus(void);
|
||||
|
@ -204,10 +204,7 @@ int queues_notification_close_id(int id, enum reason reason)
|
||||
}
|
||||
|
||||
if (target) {
|
||||
|
||||
if (reason > 0 && reason < 4)
|
||||
notification_closed(target, reason);
|
||||
|
||||
notification_closed(target, reason);
|
||||
queues_history_push(target);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user