From 2bf15202110767b6adbacc02d7e9dae1c305d944 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 29 Oct 2024 20:05:02 +0100 Subject: Fix gcc uninitialized warning in FreeBSD zio_crypt.c In FreeBSD's `zio_do_crypt_data()`, ensure that two `struct uio` variables are cleared before copying data out of them. This avoids accessing garbage data, and fixes gcc `-Wuninitialized` warnings. Reviewed-by: Brian Behlendorf Reviewed-by: Toomas Soome Reviewed-by: Alexander Motin Signed-off-by: Dimitry Andric Closes #16688 --- module/os/freebsd/zfs/zio_crypt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module') diff --git a/module/os/freebsd/zfs/zio_crypt.c b/module/os/freebsd/zfs/zio_crypt.c index 2b62abccc..feaca93fb 100644 --- a/module/os/freebsd/zfs/zio_crypt.c +++ b/module/os/freebsd/zfs/zio_crypt.c @@ -1686,11 +1686,10 @@ zio_do_crypt_data(boolean_t encrypt, zio_crypt_key_t *key, freebsd_crypt_session_t *tmpl = NULL; uint8_t *authbuf = NULL; - + memset(&puio_s, 0, sizeof (puio_s)); + memset(&cuio_s, 0, sizeof (cuio_s)); zfs_uio_init(&puio, &puio_s); zfs_uio_init(&cuio, &cuio_s); - memset(GET_UIO_STRUCT(&puio), 0, sizeof (struct uio)); - memset(GET_UIO_STRUCT(&cuio), 0, sizeof (struct uio)); #ifdef FCRYPTO_DEBUG printf("%s(%s, %p, %p, %d, %p, %p, %u, %s, %p, %p, %p)\n", -- cgit v1.2.3