Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit edddf99

Browse files
committed
Issue #22117: Add assertions to _PyTime_AsTimeval() and _PyTime_AsTimespec() to
check that microseconds and nanoseconds fits into the specified range.
1 parent ea9c0dd commit edddf99

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Python/pytime.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ _PyTime_AsTimeval_impl(_PyTime_t t, struct timeval *tv, _PyTime_round_t round,
360360

361361
if (res && raise)
362362
_PyTime_overflow();
363+
364+
assert(0 <= tv->tv_usec && tv->tv_usec <= 999999);
363365
return res;
364366
}
365367

@@ -393,6 +395,8 @@ _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts)
393395
return -1;
394396
}
395397
ts->tv_nsec = nsec;
398+
399+
assert(0 <= ts->tv_nsec && ts->tv_nsec <= 999999999);
396400
return 0;
397401
}
398402
#endif

0 commit comments

Comments
 (0)