From 39e96f844a467400cda1dd24401b2c8fbe480eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 6 Feb 2020 09:19:46 +0100 Subject: [PATCH] firstboot: add missing check If we check length of 'a', we must do the same for 'b'. --- src/firstboot/firstboot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 8001f90d57a..901fbf08159 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -550,10 +550,9 @@ static int prompt_root_password(void) { r = ask_password_tty(-1, msg1, NULL, 0, 0, NULL, &a); if (r < 0) return log_error_errno(r, "Failed to query root password: %m"); - if (strv_length(a) != 1) { - log_warning("Received multiple passwords, where we expected one."); - return -EINVAL; - } + if (strv_length(a) != 1) + return log_error_errno(SYNTHETIC_ERRNO(EIO), + "Received multiple passwords, where we expected one."); if (isempty(*a)) { log_warning("No password entered, skipping."); @@ -563,6 +562,9 @@ static int prompt_root_password(void) { r = ask_password_tty(-1, msg2, NULL, 0, 0, NULL, &b); if (r < 0) return log_error_errno(r, "Failed to query root password: %m"); + if (strv_length(b) != 1) + return log_error_errno(SYNTHETIC_ERRNO(EIO), + "Received multiple passwords, where we expected one."); if (!streq(*a, *b)) { log_error("Entered passwords did not match, please try again.");