From 1482224c546cabc3a08ec069c775b116171f182a Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Feb 2023 20:29:29 +0100 Subject: [PATCH] Use freezero(3) where suitable It originated in OpenBSD, and is available in libbsd. Signed-off-by: Alejandro Colomar --- libmisc/agetpass.c | 8 ++------ libmisc/obscure.c | 6 ++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/libmisc/agetpass.c b/libmisc/agetpass.c index f4aad7a3..63ee49a4 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 f3b7096d..6f7f33cf 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; }