From 376d5ccba116673c3f1f469a02b25aca247e9613 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 17 Apr 2026 11:52:41 +0200 Subject: [PATCH 1/3] dissect-image: fix path building for non-raw images If the passed in image path didn't end with .raw, we'd return an empty string + suffix instead of the intended image + suffix path. Follow-up for 89e62e0bd3cb72915b705b5e2da1834e4d8aea9f. --- src/shared/dissect-image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index e33e78d310..2293cd5acb 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -3728,7 +3728,7 @@ static char *build_auxiliary_path(const char *image, const char *suffix) { e = endswith(image, ".raw"); if (!e) - return strjoin(e, suffix); + return strjoin(image, suffix); n = new(char, e - image + strlen(suffix) + 1); if (!n) From 5853d0a53378ed973d8c006531846717ae55090a Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 16 Apr 2026 15:55:10 +0200 Subject: [PATCH 2/3] scsi_id: use safe_atoi() instead of plain atoi() --- src/udev/scsi_id/scsi_id.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index 6a31f9c4c8..ba7a7fe5f5 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -15,6 +15,7 @@ #include "extract-word.h" #include "fd-util.h" #include "fileio.h" +#include "parse-util.h" #include "scsi_id.h" #include "string-util.h" #include "strv.h" @@ -234,7 +235,7 @@ static void help(void) { static int set_options(int argc, char **argv, char *maj_min_dev) { - int option; + int option, r; /* * optind is a global extern used by getopt. Since we can call @@ -279,7 +280,11 @@ static int set_options(int argc, char **argv, break; case 's': - sg_version = atoi(optarg); + r = safe_atoi(optarg, &sg_version); + if (r < 0) + return log_error_errno(r, + "Invalid SG version '%s'", + optarg); if (sg_version < 3 || sg_version > 4) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown SG version '%s'", From 4977c00e2a7efda3a7be2136fe2fed4de6777565 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 16 Apr 2026 15:48:16 +0200 Subject: [PATCH 3/3] udev-builtin: add a couple of asserts --- src/udev/udev-builtin-usb_id.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index 61250b7072..cfbea9d981 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -22,6 +22,9 @@ static void set_usb_iftype(char *to, int if_class_num, size_t len) { const char *type = "generic"; + assert(to); + assert(len > 0); + switch (if_class_num) { case 1: type = "audio"; @@ -71,6 +74,8 @@ static int set_usb_mass_storage_ifsubtype(char *to, const char *from, size_t len int type_num = 0; const char *type = "generic"; + assert(to); + if (safe_atoi(from, &type_num) >= 0) switch (type_num) { case 1: /* RBC devices */ @@ -98,6 +103,8 @@ static void set_scsi_type(char *to, const char *from, size_t len) { unsigned type_num; const char *type = "generic"; + assert(to); + if (safe_atou(from, &type_num) >= 0) switch (type_num) { case 0: @@ -143,6 +150,10 @@ static int dev_if_packed_info(sd_device *dev, char *ifs_str, size_t len) { uint8_t iInterface; } _packed_; + assert(dev); + assert(ifs_str); + assert(len >= 2); + r = sd_device_get_syspath(dev, &syspath); if (r < 0) return r;