Skip to content

Commit

Permalink
bus/peer: fix catching OOM when linking match-rules
Browse files Browse the repository at this point in the history
When the match-rule infrastructure was extended to have per-key lookup
tables, all call-sites had to be amended to catch errors when linking
new rules. One such site was missed, so fix this and catch the error
properly.

The conversion was initially performed in:

    commit 6c2b082
    Author: Tom Gundersen <teg@jklm.no>
    Date:   Wed Apr 25 17:16:47 2018 +0200

        match: make match_rule_link() fallible

This fixes a possible bug where ENOMEM is ignored and thus a match rule
is silently dropped instead of being linked and retained.

Reported-by: Mark Esler <mark.esler@canonical.com>
Signed-off-by: David Rheinsberg <david@readahead.eu>
  • Loading branch information
dvdhrm committed Jun 12, 2023
1 parent 55186d5 commit af6bf48
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/bus/peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,9 @@ static int peer_link_match(Peer *peer, MatchRule *rule, bool monitor) {
case ADDRESS_TYPE_ID: {
sender = peer_registry_find_peer(&peer->bus->peers, addr.id);
if (sender) {
match_rule_link(rule, &sender->sender_matches, monitor);
r = match_rule_link(rule, &sender->sender_matches, monitor);
if (r)
return error_fold(r);
} else if (addr.id >= peer->bus->peers.ids) {
/*
* This peer does not yet exist, by the same
Expand Down

0 comments on commit af6bf48

Please sign in to comment.