Skip to content

Commit 25577cd

Browse files
committed
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 <[email protected]>
1 parent 8afc88c commit 25577cd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/rgw/rgw_lc.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,10 +2609,10 @@ bool RGWLC::going_down()
26092609

26102610
bool RGWLC::LCWorker::should_work(utime_t& now)
26112611
{
2612-
int start_hour;
2613-
int start_minute;
2614-
int end_hour;
2615-
int end_minute;
2612+
int start_hour = 0;
2613+
int start_minute = 0;
2614+
int end_hour = 23;
2615+
int end_minute = 59;
26162616
string worktime = cct->_conf->rgw_lifecycle_work_time;
26172617
sscanf(worktime.c_str(),"%d:%d-%d:%d",&start_hour, &start_minute,
26182618
&end_hour, &end_minute);
@@ -2649,10 +2649,10 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now)
26492649
return (secs);
26502650
}
26512651

2652-
int start_hour;
2653-
int start_minute;
2654-
int end_hour;
2655-
int end_minute;
2652+
int start_hour = 0;
2653+
int start_minute = 0;
2654+
int end_hour = 23;
2655+
int end_minute = 59;
26562656
string worktime = cct->_conf->rgw_lifecycle_work_time;
26572657
sscanf(worktime.c_str(),"%d:%d-%d:%d",&start_hour, &start_minute, &end_hour,
26582658
&end_minute);

0 commit comments

Comments
 (0)