Fixed buffer overflows in sunrise_sunset_face

This commit is contained in:
hueso 2025-05-15 11:59:21 -03:00
parent ff8cf346be
commit 4c8d04030c

View File

@ -108,7 +108,7 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
watch_clear_indicator(WATCH_INDICATOR_24H);
if (result == 1) watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "SET", "SE");
else watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "RIS", "rI");
sprintf(buf, "%2d", scratch_time.unit.day);
snprintf(buf, sizeof(buf), "%2d", scratch_time.unit.day);
watch_display_text(WATCH_POSITION_TOP_RIGHT, buf);
watch_display_text(WATCH_POSITION_BOTTOM, "None ");
return;
@ -149,9 +149,9 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
else watch_clear_indicator(WATCH_INDICATOR_PM);
}
watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "RIS", "rI");
sprintf(buf, "%2d", scratch_time.unit.day);
snprintf(buf, sizeof(buf), "%2d", scratch_time.unit.day);
watch_display_text(WATCH_POSITION_TOP_RIGHT, buf);
sprintf(buf, "%2d%02d%2s", scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
snprintf(buf, sizeof(buf), "%2d%02d%2s", scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
watch_display_text(WATCH_POSITION_BOTTOM, buf);
return;
} else {
@ -188,9 +188,9 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
else watch_clear_indicator(WATCH_INDICATOR_PM);
}
watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "SET", "SE");
sprintf(buf, "%2d", scratch_time.unit.day);
snprintf(buf, sizeof(buf), "%2d", scratch_time.unit.day);
watch_display_text(WATCH_POSITION_TOP_RIGHT, buf);
sprintf(buf, "%2d%02d%2s", scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
snprintf(buf, sizeof(buf), "%2d%02d%2s", scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
watch_display_text(WATCH_POSITION_BOTTOM, buf);
return;
} else {
@ -274,7 +274,7 @@ static void _sunrise_sunset_face_update_settings_display(movement_event_t event,
if (state->active_digit == 4) watch_display_character(' ', 9);
}
} else {
sprintf(buf, "%c %04d", state->working_latitude.sign ? '-' : '+', abs(_sunrise_sunset_face_latlon_from_struct(state->working_latitude)));
snprintf(buf, sizeof(buf), "%c %04d", state->working_latitude.sign ? '-' : '+', abs(_sunrise_sunset_face_latlon_from_struct(state->working_latitude)));
if (event.subsecond % 2) buf[state->active_digit] = ' ';
watch_display_text(WATCH_POSITION_BOTTOM, buf);
}
@ -301,7 +301,7 @@ static void _sunrise_sunset_face_update_settings_display(movement_event_t event,
if (state->active_digit == 4) watch_display_character(' ', 9);
}
} else {
sprintf(buf, "%c%05d", state->working_longitude.sign ? '-' : '+', abs(_sunrise_sunset_face_latlon_from_struct(state->working_longitude)));
snprintf(buf, sizeof(buf), "%c%05d", state->working_longitude.sign ? '-' : '+', abs(_sunrise_sunset_face_latlon_from_struct(state->working_longitude)));
if (event.subsecond % 2) buf[state->active_digit] = ' ';
watch_display_text(WATCH_POSITION_BOTTOM, buf);
}