From 84f8e7c06ad20cdbaebf0120bb46225b17737943 Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Jun 17 2026 10:17:01 +0000 Subject: fix possible null pointer dereference, as reported by SAST scan A null pointer dereference occurs in `libvk_volume_free` if it's called on a partially initialized `libvk_volume` struct. The function `volume_load_escrow_packet` allocates a zeroed struct, and if it fails to parse the `VOLUME_FORMAT` attribute from the input packet, it calls `libvk_volume_free` in its error path. At this point, `vol->format` is still `NULL`, causing `strcmp(vol->format, ...)` to crash. --- diff --git a/lib/volume.c b/lib/volume.c index bfcc383..8d3a53d 100644 --- a/lib/volume.c +++ b/lib/volume.c @@ -281,7 +281,7 @@ libvk_volume_free (struct libvk_volume *vol) { g_return_if_fail (vol != NULL); - if (strcmp (vol->format, LIBVK_VOLUME_FORMAT_LUKS) == 0 + if (vol->format != NULL && strcmp (vol->format, LIBVK_VOLUME_FORMAT_LUKS) == 0 && vol->v.luks != NULL) luks_volume_free (vol->v.luks); g_free (vol->hostname);