From 9c2f7a931ce5070d2eb22194b1acbd2522c55efe Mon Sep 17 00:00:00 2001 From: William Casarin Date: Wed, 3 Jan 2024 14:44:54 -0800 Subject: [PATCH] nostrdb/subs: always fail when calling wait_for_notes on a subid of 0 this is an invalid subscription id Signed-off-by: William Casarin --- nostrdb/src/nostrdb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c index b589f2d3..e441ef40 100644 --- a/nostrdb/src/nostrdb.c +++ b/nostrdb/src/nostrdb.c @@ -4954,6 +4954,11 @@ int ndb_wait_for_notes(struct ndb *ndb, uint64_t subid, uint64_t *note_ids, int note_id_capacity) { struct ndb_subscription *sub; + + // this is not a valid subscription id + if (subid == 0) + return 0; + if (!(sub = ndb_find_subscription(ndb, subid))) return 0;