]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin: add a couple of asserts 41674/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 16 Apr 2026 13:48:16 +0000 (15:48 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 17 Apr 2026 10:37:30 +0000 (12:37 +0200)
src/udev/udev-builtin-usb_id.c

index 61250b7072fe03b37e5253fc6031e324820b1b00..cfbea9d9819dcbe7fc63efaeab4110a4f8be5da5 100644 (file)
@@ -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;