[PATCH] Simplify code with freezero

Tobias Stoeckmann tobias at stoeckmann.org
Wed Aug 14 03:09:29 AEST 2024


The freezero call is practically the same as calling explicit_bzero
followed by free.

Okay?

Index: sshbuf.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/sshbuf.c,v
diff -u -p -u -p -r1.19 sshbuf.c
--- sshbuf.c	2 Dec 2022 04:40:27 -0000	1.19
+++ sshbuf.c	13 Aug 2024 16:54:20 -0000
@@ -183,10 +183,8 @@ sshbuf_free(struct sshbuf *buf)
 	sshbuf_free(buf->parent);
 	buf->parent = NULL;

-	if (!buf->readonly) {
-		explicit_bzero(buf->d, buf->alloc);
-		free(buf->d);
-	}
+	if (!buf->readonly)
+		freezero(buf->d, buf->alloc);
 	freezero(buf, sizeof(*buf));
 }



More information about the openssh-unix-dev mailing list