chiark / gitweb /
udev/ata_id: zero out variable properly
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 14 Apr 2013 22:48:45 +0000 (18:48 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 14 Apr 2013 22:52:24 +0000 (18:52 -0400)
b8a2b0f76 'use initalization instead of explicit zeroing'
introduced a bug where only the first sizeof(uint_t*) bytes
would be zeroed out, instead of the whole array.

src/udev/ata_id/ata_id.c

index 4d30fd899468d3198ebcb31eb661f8594d835416..68a06b93b8272e24f89b726eb72d2f6303722152 100644 (file)
@@ -334,11 +334,10 @@ static int disk_identify(struct udev *udev,
         int peripheral_device_type;
         int all_nul_bytes;
         int n;
-        int is_packet_device;
+        int is_packet_device = 0;
 
         /* init results */
-        zero(out_identify);
-        is_packet_device = 0;
+        memzero(out_identify, 512);
 
         /* If we were to use ATA PASS_THROUGH (12) on an ATAPI device
          * we could accidentally blank media. This is because MMC's BLANK
@@ -402,7 +401,7 @@ static int disk_identify(struct udev *udev,
 
 out:
         if (out_is_packet_device != NULL)
-          *out_is_packet_device = is_packet_device;
+                *out_is_packet_device = is_packet_device;
         return ret;
 }