Skip to content

Commit f3db5ff

Browse files
Fix cover_travel_time() overflow for travel times > 65 s
cover_travel_time() returned uint16_t but multiplied open_time/close_time (which are stored in tenths of a second) by 100 to convert to milliseconds. For travel times above 65.5 s (655 tenths), the result exceeded 65535 and silently wrapped. A 66 s travel time (660 tenths) would produce 464 ms instead of 66000 ms. Co-authored-by: yarfalksol <285298507+yarfalksol@users.noreply.github.com>
1 parent 0564bee commit f3db5ff

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/zigbee/cover_cluster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ static uint8_t window_covering_type = 0;
5151
* configured, the open_time is used for both directions. This allows a single open_time value to
5252
* cover both directions for symmetric covers.
5353
*/
54-
static uint16_t cover_travel_time(zigbee_cover_cluster *cluster, uint8_t direction) {
54+
static uint32_t cover_travel_time(zigbee_cover_cluster *cluster, uint8_t direction) {
5555
uint16_t travel_time = cluster->open_time;
5656

5757
if (direction == ZCL_ATTR_WINDOW_COVERING_MOVING_CLOSING && cluster->close_time > 0) {
5858
travel_time = cluster->close_time;
5959
}
6060

61-
return travel_time * 100; // Convert from tenth of seconds to milliseconds
61+
return (uint32_t)travel_time * 100; // Convert from tenth of seconds to milliseconds
6262
}
6363

6464
/**

0 commit comments

Comments
 (0)