Fix uninitialized read in doveadm-oldstats
authorChristian Göttsche <cgzones@googlemail.com>
Sat, 23 Jul 2022 14:38:23 +0000 (16:38 +0200)
committerPeter Michael Green <plugwash@raspbian.org>
Thu, 20 Jun 2024 17:16:27 +0000 (17:16 +0000)
The third argument to doveadm_cmd_param_bool() is only set on a return
value of TRUE.
Since disk_input_field and disk_output_field should be set if the value
of show-disk-io is specified and specified to true, fix the condition.

    doveadm-oldstats.c: In function 'cmd_stats_top':
    doveadm-oldstats.c:551:63: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
      551 |         if (!doveadm_cmd_param_bool(cctx, "show-disk-io", &b) && b) {
          |                                                               ^
    doveadm-oldstats.c:545:14: note: 'b' was declared here
      545 |         bool b;
          |              ^

Gbp-Pq: Name Fix-uninitialized-read-in-doveadm-oldstats.patch

src/doveadm/doveadm-oldstats.c

index 4be575ea92dadc4b0a1dbff705f726b11a827c38..ff6dcf5428d0f5bc140d8ccf85025cbd7530213e 100644 (file)
@@ -548,7 +548,7 @@ static void cmd_stats_top(struct doveadm_cmd_context *cctx)
                path = t_strconcat(doveadm_settings->base_dir,
                                   "/old-stats", NULL);
        }
-       if (!doveadm_cmd_param_bool(cctx, "show-disk-io", &b) && b) {
+       if (doveadm_cmd_param_bool(cctx, "show-disk-io", &b) && b) {
                disk_input_field = "read_bytes";
                disk_output_field = "write_bytes";
        }