@@ -169,7 +169,16 @@ static int ask_password_keyring(const char *keyname, AskPasswordFlags flags, cha
169169 return r ;
170170 }
171171
172- return retrieve_key (serial , ret );
172+ _cleanup_strv_free_erase_ char * * l = NULL ;
173+ r = retrieve_key (serial , & l );
174+ if (r < 0 )
175+ return r ;
176+
177+ if (strv_isempty (l ))
178+ return log_debug_errno (SYNTHETIC_ERRNO (ENOKEY ), "Found an empty password from keyring." );
179+
180+ * ret = TAKE_PTR (l );
181+ return 0 ;
173182}
174183
175184static int backspace_chars (int ttyfd , size_t p ) {
@@ -326,8 +335,8 @@ int ask_password_plymouth(
326335 return - ENOENT ;
327336
328337 } else if (IN_SET (buffer [0 ], 2 , 9 )) {
338+ _cleanup_strv_free_erase_ char * * l = NULL ;
329339 uint32_t size ;
330- char * * l ;
331340
332341 /* One or more answers */
333342 if (p < 5 )
@@ -345,15 +354,16 @@ int ask_password_plymouth(
345354 if (!l )
346355 return - ENOMEM ;
347356
348- * ret = l ;
349- break ;
357+ if (strv_isempty (l ))
358+ return log_debug_errno (SYNTHETIC_ERRNO (ECANCELED ), "Received an empty password." );
359+
360+ * ret = TAKE_PTR (l );
361+ return 0 ;
350362
351363 } else
352364 /* Unknown packet */
353365 return - EIO ;
354366 }
355-
356- return 0 ;
357367}
358368
359369#define NO_ECHO "(no echo) "
@@ -948,8 +958,8 @@ int ask_password_agent(
948958
949959static int ask_password_credential (const char * credential_name , AskPasswordFlags flags , char * * * ret ) {
950960 _cleanup_ (erase_and_freep ) char * buffer = NULL ;
961+ _cleanup_strv_free_erase_ char * * l = NULL ;
951962 size_t size ;
952- char * * l ;
953963 int r ;
954964
955965 assert (credential_name );
@@ -963,7 +973,10 @@ static int ask_password_credential(const char *credential_name, AskPasswordFlags
963973 if (!l )
964974 return - ENOMEM ;
965975
966- * ret = l ;
976+ if (strv_isempty (l ))
977+ return log_debug_errno (SYNTHETIC_ERRNO (ENOKEY ), "Found an empty password in credential." );
978+
979+ * ret = TAKE_PTR (l );
967980 return 0 ;
968981}
969982
0 commit comments