Skip to content

Commit

Permalink
Fix gcc uninitialized warning in FreeBSD zio_crypt.c
Browse files Browse the repository at this point in the history
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 `-Wunitialized` warnings.

Signed-off-by: Dimitry Andric <dimitry@andric.com>
  • Loading branch information
DimitryAndric committed Oct 25, 2024
1 parent e5d1f68 commit e906aec
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions module/os/freebsd/zfs/zio_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e906aec

Please sign in to comment.