# HG changeset patch # User Paul Boddie # Date 1714950849 -7200 # Node ID 5b77aef76beac37486d5337021df112dae5dcd6b # Parent 4cc3e52e39fb014bd7b7e60310b8f98dbfac96e8 Fixed buffer descriptor register initialisation for currently supported usage. Fixed handling of invalid received capabilities (again), leaving allocated capabilities in place for use by valid received capabilities. diff -r 4cc3e52e39fb -r 5b77aef76bea libipc/lib/src/message.c --- a/libipc/lib/src/message.c Mon May 06 01:09:30 2024 +0200 +++ b/libipc/lib/src/message.c Mon May 06 01:14:09 2024 +0200 @@ -213,7 +213,12 @@ msg->discarded_items = 0; msg->words = 0; msg->items = 0; + + /* Initialise items to be received. + NOTE: This does not support item type mixing. */ + msg->import_item = 0; + msg->bregs.bdr = 0; /* Message label overriding. */ @@ -510,8 +515,16 @@ if (local) return L4_EOK; - err = ipc_message_expect_capability(msg, msg->import_item); - msg->import_item += 1; + /* Only if the specified item yielded a valid capability, will an allocated + have been consumed. Otherwise, the next allocated capability will still be + available. */ + + if (l4_is_valid_cap(*ref)) + { + err = ipc_message_expect_capability(msg, msg->import_item); + msg->import_item += 1; + } + return err; } diff -r 4cc3e52e39fb -r 5b77aef76bea libipc/lib/src/util_ipc.c --- a/libipc/lib/src/util_ipc.c Mon May 06 01:09:30 2024 +0200 +++ b/libipc/lib/src/util_ipc.c Mon May 06 01:14:09 2024 +0200 @@ -60,7 +60,6 @@ /* Indicate the expectation of a capability in return. */ - bregs->bdr = 0; bregs->br[item] = L4_RCV_ITEM_SINGLE_CAP | future | L4_RCV_ITEM_LOCAL_ID; return L4_EOK; @@ -70,7 +69,6 @@ long _expect_fpage(l4_buf_regs_t *bregs, int item, l4_umword_t map_control, l4_fpage_t fpage) { - bregs->bdr = 0; bregs->br[item] = map_control; bregs->br[item + 1] = fpage.raw;