@@ -168,7 +168,16 @@ static int ask_password_keyring(const char *keyname, AskPasswordFlags flags, cha
168168 if (r < 0 )
169169 return r ;
170170
171- return retrieve_key (serial , ret );
171+ _cleanup_strv_free_erase_ char * * l = NULL ;
172+ r = retrieve_key (serial , & l );
173+ if (r < 0 )
174+ return r ;
175+
176+ if (strv_isempty (l ))
177+ return log_debug_errno (SYNTHETIC_ERRNO (ENOKEY ), "Found an empty password from keyring." );
178+
179+ * ret = TAKE_PTR (l );
180+ return 0 ;
172181}
173182
174183static int backspace_chars (int ttyfd , size_t p ) {
@@ -321,8 +330,8 @@ int ask_password_plymouth(
321330 return - ENOENT ;
322331
323332 } else if (IN_SET (buffer [0 ], 2 , 9 )) {
333+ _cleanup_strv_free_erase_ char * * l = NULL ;
324334 uint32_t size ;
325- char * * l ;
326335
327336 /* One or more answers */
328337 if (p < 5 )
@@ -340,15 +349,16 @@ int ask_password_plymouth(
340349 if (!l )
341350 return - ENOMEM ;
342351
343- * ret = l ;
344- break ;
352+ if (strv_isempty (l ))
353+ return log_debug_errno (SYNTHETIC_ERRNO (ECANCELED ), "Received an empty password." );
354+
355+ * ret = TAKE_PTR (l );
356+ return 0 ;
345357
346358 } else
347359 /* Unknown packet */
348360 return - EIO ;
349361 }
350-
351- return 0 ;
352362}
353363
354364#define NO_ECHO "(no echo) "
@@ -944,8 +954,8 @@ int ask_password_agent(
944954
945955static int ask_password_credential (const char * credential_name , AskPasswordFlags flags , char * * * ret ) {
946956 _cleanup_ (erase_and_freep ) char * buffer = NULL ;
957+ _cleanup_strv_free_erase_ char * * l = NULL ;
947958 size_t size ;
948- char * * l ;
949959 int r ;
950960
951961 assert (credential_name );
@@ -959,7 +969,10 @@ static int ask_password_credential(const char *credential_name, AskPasswordFlags
959969 if (!l )
960970 return - ENOMEM ;
961971
962- * ret = l ;
972+ if (strv_isempty (l ))
973+ return log_debug_errno (SYNTHETIC_ERRNO (ENOKEY ), "Found an empty password in credential." );
974+
975+ * ret = TAKE_PTR (l );
963976 return 0 ;
964977}
965978
0 commit comments