diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-12-14 05:40:42 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-12-14 16:07:17 +0100 |
commit | 75fa1f25c08a4b5dc2180893718473be9e4f6bab (patch) | |
tree | 1f2acbd356fee1d74117fdc8ba40e3a5e13f70c9 | |
parent | sd-id128: allow sd_id128_get_machine() and friend to be called with NULL (diff) | |
download | systemd-75fa1f25c08a4b5dc2180893718473be9e4f6bab.tar.xz systemd-75fa1f25c08a4b5dc2180893718473be9e4f6bab.zip |
sd-id128: also refuse an empty invocation ID
-rw-r--r-- | man/sd_id128_get_machine.xml | 3 | ||||
-rw-r--r-- | src/libsystemd/sd-id128/sd-id128.c | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/man/sd_id128_get_machine.xml b/man/sd_id128_get_machine.xml index 4f6926fd7d..075caffb2b 100644 --- a/man/sd_id128_get_machine.xml +++ b/man/sd_id128_get_machine.xml @@ -139,7 +139,8 @@ <listitem><para>Returned by <function>sd_id128_get_machine()</function> and <function>sd_id128_get_machine_app_specific()</function> when <filename>/etc/machine-id</filename> - is empty or all zeros.</para></listitem> + is empty or all zeros. Also returned by <function>sd_id128_get_invocation()</function> when the + invocation ID is all zeros.</para></listitem> </varlistentry> <varlistentry> diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c index 9fac1bb3fc..ec3a496dba 100644 --- a/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libsystemd/sd-id128/sd-id128.c @@ -284,6 +284,9 @@ _public_ int sd_id128_get_invocation(sd_id128_t *ret) { r = get_invocation_from_keyring(&saved_invocation_id); if (r < 0) return r; + + if (sd_id128_is_null(saved_invocation_id)) + return -ENOMEDIUM; } if (ret) |