Skip to content

Commit a24483b

Browse files
matteiusCopilot
andauthored
Update src/web/api_handlers_motion.c
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c98b245 commit a24483b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/web/api_handlers_motion.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,22 @@ void handle_post_motion_trigger(const http_request_t *req, http_response_t *res)
146146
"Field 'duration_ms' must be a positive integer");
147147
return;
148148
}
149-
int d = (int)j_duration->valuedouble;
150-
if (d <= 0 || d > MOTION_PULSE_MAX_MS) {
149+
150+
double duration_value = j_duration->valuedouble;
151+
if (duration_value <= 0 || duration_value > MOTION_PULSE_MAX_MS) {
151152
cJSON_Delete(body);
152153
http_response_set_json_error(res, 400,
153154
"Field 'duration_ms' must be between 1 and 600000");
154155
return;
155156
}
157+
158+
int d = (int)duration_value;
159+
if ((double)d != duration_value) {
160+
cJSON_Delete(body);
161+
http_response_set_json_error(res, 400,
162+
"Field 'duration_ms' must be a positive integer");
163+
return;
164+
}
156165
duration_ms = d;
157166
}
158167

0 commit comments

Comments
 (0)