diff options
author | Justus Winter <justus@gnupg.org> | 2016-11-01 12:29:25 +0100 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2016-11-01 15:18:19 +0100 |
commit | dfd5134090dd80957dce5a65b467aafaff47ca3b (patch) | |
tree | 331bd43af3cb2250aec9641cc0d6d9ab2ecdf0b9 /boot | |
parent | 34b5aa167da439900c4c1d1bb45b642b47d9a572 (diff) |
boot: Use the smallest possible name when inserting rights.
* boot/userland-boot.c (boot_script_insert_right): Use the smallest
possible name instead of the local name.
Diffstat (limited to 'boot')
-rw-r--r-- | boot/userland-boot.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/boot/userland-boot.c b/boot/userland-boot.c index d048c00e..7b856147 100644 --- a/boot/userland-boot.c +++ b/boot/userland-boot.c @@ -90,14 +90,23 @@ boot_script_free_task (task_t task, int aborting) int boot_script_insert_right (struct cmd *cmd, mach_port_t port, mach_port_t *name) { - error_t err = mach_port_insert_right (cmd->task, - port, port, MACH_MSG_TYPE_COPY_SEND); + error_t err; + + *name = MACH_PORT_NULL; + do + { + *name += 1; + err = mach_port_insert_right (cmd->task, + *name, port, MACH_MSG_TYPE_COPY_SEND); + } + while (err == KERN_NAME_EXISTS); + if (err) { error (0, err, "%s: mach_port_insert_right", cmd->path); return BOOT_SCRIPT_MACH_ERROR; } - *name = port; + return 0; } |