From: Alejandro Colomar Date: Wed, 1 Feb 2023 19:29:29 +0000 (+0100) Subject: Use freezero(3) where suitable X-Git-Tag: 4.14.0-rc1~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1482224c546cabc3a08ec069c775b116171f182a;p=thirdparty%2Fshadow.git Use freezero(3) where suitable It originated in OpenBSD, and is available in libbsd. Signed-off-by: Alejandro Colomar --- diff --git a/libmisc/agetpass.c b/libmisc/agetpass.c index f4aad7a30..63ee49a4d 100644 --- a/libmisc/agetpass.c +++ b/libmisc/agetpass.c @@ -136,8 +136,7 @@ agetpass(const char *prompt) return pass; fail: - memzero(pass, PASS_MAX); - free(pass); + freezero(pass, PASS_MAX); return NULL; } @@ -145,8 +144,5 @@ fail: void erase_pass(char *pass) { - if (pass == NULL) - return; - memzero(pass, PASS_MAX); - free(pass); + freezero(pass, PASS_MAX); } diff --git a/libmisc/obscure.c b/libmisc/obscure.c index f3b7096d9..6f7f33cf7 100644 --- a/libmisc/obscure.c +++ b/libmisc/obscure.c @@ -274,10 +274,8 @@ static /*@observer@*//*@null@*/const char *obscure_msg ( msg = password_check (old1, new1, pwdp); - memzero (new1, newlen); - memzero (old1, oldlen); - free (new1); - free (old1); + freezero (new1, newlen); + freezero (old1, oldlen); return msg; }