From: Casey Bodley Date: Wed, 17 Sep 2025 17:30:22 +0000 (-0400) Subject: rgw/lc: initialize variables passed to sscanf() X-Git-Tag: testing/wip-vshankar-testing-20251027.053005-debug~47^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=25577cd3b0ef9b16f8c8e38334d0ee023967df66;p=ceph-ci.git rgw/lc: initialize variables passed to sscanf() 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 --- diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 1fbca2f0968..8981c26dc81 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -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);