X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fask-password-api.c;h=04d5623d9ee19597bf849de6a13c7c018d5b5dcf;hp=da967ab7a1a638b10163fef471755a2652809d05;hb=ec2002f84928c0b5921a961cb2b8637563f29daa;hpb=441dfe092acb0f283f7712a80e144b4392b526a0 diff --git a/src/ask-password-api.c b/src/ask-password-api.c index da967ab7a..04d5623d9 100644 --- a/src/ask-password-api.c +++ b/src/ask-password-api.c @@ -404,13 +404,13 @@ int ask_password_agent( t = now(CLOCK_MONOTONIC); - if (until <= t) { + if (until > 0 && until <= t) { log_notice("Timed out"); r = -ETIME; goto finish; } - if ((k = poll(pollfd, _FD_MAX, (until-t)/USEC_PER_MSEC)) < 0) { + if ((k = poll(pollfd, _FD_MAX, until > 0 ? (int) ((until-t)/USEC_PER_MSEC) : -1)) < 0) { if (errno == EINTR) continue; @@ -481,7 +481,13 @@ int ask_password_agent( if (passphrase[0] == '+') { char **l; - if (!(l = strv_parse_nulstr(passphrase+1, n-1))) { + if (n == 1) + l = strv_new("", NULL); + else + l = strv_parse_nulstr(passphrase+1, n-1); + /* An empty message refers to the empty password */ + + if (!l) { r = -ENOMEM; goto finish; }