1.1 --- a/libipc/lib/src/message.c Mon Dec 11 17:26:53 2023 +0100
1.2 +++ b/libipc/lib/src/message.c Mon Dec 11 19:17:25 2023 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Interprocess communication message abstraction.
1.6 *
1.7 - * Copyright (C) 2018, 2019, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2018, 2019, 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -444,8 +444,16 @@
1.13
1.14 void ipc_message_export_capability(ipc_message_t *msg, int item, l4_cap_idx_t ref)
1.15 {
1.16 - msg->mregs.mr[msg->words + item * 2] = 0 | L4_ITEM_MAP;
1.17 - msg->mregs.mr[msg->words + item * 2 + 1] = l4_obj_fpage(ref, 0, L4_FPAGE_RWX).raw;
1.18 + if (l4_is_valid_cap(ref))
1.19 + {
1.20 + msg->mregs.mr[msg->words + item * 2] = 0 | L4_ITEM_MAP;
1.21 + msg->mregs.mr[msg->words + item * 2 + 1] = l4_obj_fpage(ref, 0, L4_FPAGE_RWX).raw;
1.22 + }
1.23 + else
1.24 + {
1.25 + msg->mregs.mr[msg->words + item * 2] = 0;
1.26 + msg->mregs.mr[msg->words + item * 2 + 1] = 0;
1.27 + }
1.28 }
1.29
1.30 /* Export a flexpage at the given position in the message. Here, the snd_base
2.1 --- a/libipc/lib/src/util_ipc.c Mon Dec 11 17:26:53 2023 +0100
2.2 +++ b/libipc/lib/src/util_ipc.c Mon Dec 11 19:17:25 2023 +0100
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * Interprocess communication abstractions.
2.6 *
2.7 - * Copyright (C) 2018, 2019, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2018, 2019, 2021, 2022, 2023 Paul Boddie <paul@boddie.org.uk>
2.9 *
2.10 * This program is free software; you can redistribute it and/or
2.11 * modify it under the terms of the GNU General Public License as
2.12 @@ -154,10 +154,10 @@
2.13 *local = 1;
2.14 }
2.15
2.16 - /* Unsupported item. */
2.17 + /* Unsupported item which may legitimately be an invalid capability. */
2.18
2.19 else
2.20 - return -L4_EIO;
2.21 + *ref = L4_INVALID_CAP;
2.22
2.23 return L4_EOK;
2.24 }