]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/lc: initialize variables passed to sscanf()
authorCasey Bodley <cbodley@redhat.com>
Wed, 17 Sep 2025 17:30:22 +0000 (13:30 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 17 Sep 2025 17:30:24 +0000 (13:30 -0400)
we're not checking the return value of sscanf(), which says how many of
the expected values it successfully parsed. given an invalid
rgw_lifecycle_work_time string, any unparsed values would remain
uninitialized - so preinitialize them with reasonable defaults

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_lc.cc

index 1fbca2f0968df1d9c775031ebc734cb043cea13e..8981c26dc81beff96abf80ae39651f30190877df 100644 (file)
@@ -2609,10 +2609,10 @@ bool RGWLC::going_down()
 
 bool RGWLC::LCWorker::should_work(utime_t& now)
 {
-  int start_hour;
-  int start_minute;
-  int end_hour;
-  int end_minute;
+  int start_hour = 0;
+  int start_minute = 0;
+  int end_hour = 23;
+  int end_minute = 59;
   string worktime = cct->_conf->rgw_lifecycle_work_time;
   sscanf(worktime.c_str(),"%d:%d-%d:%d",&start_hour, &start_minute,
         &end_hour, &end_minute);
@@ -2649,10 +2649,10 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now)
        return (secs);
   }
 
-  int start_hour;
-  int start_minute;
-  int end_hour;
-  int end_minute;
+  int start_hour = 0;
+  int start_minute = 0;
+  int end_hour = 23;
+  int end_minute = 59;
   string worktime = cct->_conf->rgw_lifecycle_work_time;
   sscanf(worktime.c_str(),"%d:%d-%d:%d",&start_hour, &start_minute, &end_hour,
         &end_minute);