Skip to content

Commit 9ade91e

Browse files
committed
Fix a couple possible unsigned integer overflow bugs
1 parent d8df2b0 commit 9ade91e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/kloak.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ static int64_t current_time_ms(void) {
475475
int64_t result = 0;
476476

477477
clock_gettime(CLOCK_MONOTONIC, &spec);
478-
result = (spec.tv_sec * 1000) + (spec.tv_nsec / 1000000);
478+
assert(spec.tv_sec < INT64_MAX);
479+
result = ((int64_t)spec.tv_sec * 1000) + (spec.tv_nsec / 1000000);
479480
assert(result >= 0);
480481
if (start_time == 0) {
481482
start_time = result;
@@ -1527,7 +1528,7 @@ static void layer_surface_configure(void *data,
15271528
}
15281529
}
15291530
assert(layer != NULL);
1530-
assert(width * 4 <= INT32_MAX);
1531+
assert(width <= INT32_MAX / 4);
15311532
assert(height <= INT32_MAX);
15321533
layer->width = (int32_t)(width);
15331534
layer->height = (int32_t)(height);

0 commit comments

Comments
 (0)