Skip to content

Commit 2bf1520

Browse files
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 <behlendorf1@llnl.gov> Reviewed-by: Toomas Soome <tsoome@me.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Dimitry Andric <dimitry@andric.com> Closes openzfs#16688
1 parent c480e06 commit 2bf1520

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

module/os/freebsd/zfs/zio_crypt.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,11 +1686,10 @@ zio_do_crypt_data(boolean_t encrypt, zio_crypt_key_t *key,
16861686
freebsd_crypt_session_t *tmpl = NULL;
16871687
uint8_t *authbuf = NULL;
16881688

1689-
1689+
memset(&puio_s, 0, sizeof (puio_s));
1690+
memset(&cuio_s, 0, sizeof (cuio_s));
16901691
zfs_uio_init(&puio, &puio_s);
16911692
zfs_uio_init(&cuio, &cuio_s);
1692-
memset(GET_UIO_STRUCT(&puio), 0, sizeof (struct uio));
1693-
memset(GET_UIO_STRUCT(&cuio), 0, sizeof (struct uio));
16941693

16951694
#ifdef FCRYPTO_DEBUG
16961695
printf("%s(%s, %p, %p, %d, %p, %p, %u, %s, %p, %p, %p)\n",

0 commit comments

Comments
 (0)