Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a807a55

Browse files
committed
fix ssu_crontab period check bug
1 parent a987747 commit a807a55

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎ssu_crontab.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ bool is_period(char *period, int period_type) // 주기 인자 검사
274274
operator = 0;
275275
memset(target, 0, BUFFER_SIZE);
276276
memset(unit, 0, BUFFER_SIZE);
277-
sscanf(period_token[i], "%[^/(-)]%c%s", target, &operator, unit); // 슬래시 우선 토큰 분리
277+
if (strchr(period_token[i], '-') && strchr(period_token[i], '/')) // 슬래시와 범위가 둘다 포함되는 경우
278+
sscanf(period_token[i], "%[^/]%c%s", target, &operator, unit);
279+
else // 둘중 하나만 포함되는 경우
280+
sscanf(period_token[i], "%[^-/]%c%s", target, &operator, unit);
278281
#ifdef DEBUG
279282
printf("is_period(): target = %s, operator = %c, unit = %s\n", target, operator, unit);
280283
#endif
@@ -291,8 +294,8 @@ bool is_period(char *period, int period_type) // 주기 인자 검사
291294
if (strchr(target, '*') != NULL || strchr(unit, '*') != NULL)
292295
return false;
293296

294-
// 3-3. 뒤의 수가 앞의 수보다 클 경우
295-
if (atoi(target) < atoi(unit))
297+
// 3-3. 앞의 수가 뒤의 수보다 클 경우
298+
if (atoi(target) > atoi(unit))
296299
return false;
297300

298301
// 3-4 허용 범위를 초과했을 경우
@@ -344,8 +347,8 @@ bool is_period(char *period, int period_type) // 주기 인자 검사
344347
if (strchr(unit, '/') != NULL || strchr(unit, '-') != NULL)
345348
return false;
346349

347-
// 4-2. 시작, 끝의 범위가 전체(*)로 끝날 경우
348-
if ((strchr(target, '*') !=NULL&&strlen(unit) !=1) ||strchr(unit, '*') != NULL)
350+
// 4-2. 끝의 범위가 전체(*)로 끝날 경우
351+
if (strchr(unit, '*') != NULL)
349352
return false;
350353

351354
// 4-3. 앞 토큰이 범위일 경우

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /