6 Commits

Author SHA1 Message Date
hueso
2dfe165f22 moar fixes
Some checks failed
Build / build (push) Has been cancelled
Build / build-simulator (push) Has been cancelled
2025-05-16 18:58:52 -03:00
hueso
13863d32ca fixes 2025-05-16 18:41:17 -03:00
hueso
48399312be moonrise: only show future events
Some checks failed
Build / build (push) Has been cancelled
Build / build-simulator (push) Has been cancelled
2025-05-15 12:01:41 -03:00
hueso
736c04c688 moonrise: fixed buffer overflows and weird conditionals 2025-05-15 12:01:41 -03:00
hueso
54d5e6a8ab Moonrise face 2025-05-15 12:01:41 -03:00
hueso
8abf6f4f5b Fixed buffer overflows in sunrise_sunset_face
Some checks failed
Build / build (push) Has been cancelled
Build / build-simulator (push) Has been cancelled
GitHub Pages / gh-pages (push) Has been cancelled
2025-05-15 11:59:21 -03:00
2 changed files with 9 additions and 26 deletions

View File

@@ -43,15 +43,6 @@ static void _moonrise_face_update(movement_settings_t *settings, moonrise_state_
char buf[11];
movement_location_t movement_location;
watch_clear_colon();
watch_clear_indicator(WATCH_INDICATOR_PM);
watch_clear_indicator(WATCH_INDICATOR_24H);
// watch_display_string("__ _ ", 0);
if(state->rise_index == 0)
watch_display_string("M~ rise", 0);
else
watch_display_string("M_ set ", 0);
if (state->longLatToUse == 0 || _location_count <= 1)
movement_location = (movement_location_t) watch_get_backup_data(1);
else{
@@ -69,13 +60,8 @@ static void _moonrise_face_update(movement_settings_t *settings, moonrise_state_
watch_date_time scratch_time; // scratchpad, contains different values at different times
scratch_time.reg = date_time.reg;
// Weird quirky unsigned things were happening when I tried to cast these directly to doubles below.
// it looks redundant, but extracting them to local int16's seemed to fix it.
int16_t lat_centi = (int16_t)movement_location.bit.latitude;
int16_t lon_centi = (int16_t)movement_location.bit.longitude;
double lat = (double)lat_centi / 100.0;
double lon = (double)lon_centi / 100.0;
double lat = (double)movement_location.bit.latitude / 100.0;
double lon = (double)movement_location.bit.longitude / 100.0;
uint32_t t = watch_utility_date_time_to_unix_time(date_time, movement_timezone_offsets[settings->bit.time_zone] * 60);
MoonRise mr = MoonRise_calculate(lat, lon, t);
@@ -92,9 +78,6 @@ static void _moonrise_face_update(movement_settings_t *settings, moonrise_state_
watch_clear_indicator(WATCH_INDICATOR_24H);
snprintf(buf, sizeof(buf), "%s%2d none ", state->rise_index ? "M_" : "M~", scratch_time.unit.day);
watch_display_string(buf, 0);
state->rise_set_expires = watch_utility_date_time_from_unix_time(
watch_utility_offset_timestamp(t, MR_WINDOW, 0, 0),
movement_timezone_offsets[settings->bit.time_zone] * 60);
return;
}
watch_set_colon();

View File

@@ -45,7 +45,7 @@ static void _sunrise_sunset_set_expiration(sunrise_sunset_state_t *state, watch_
}
static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_sunset_state_t *state) {
char buf[14];
char buf[11];
double rise, set, minutes, seconds;
bool show_next_match = false;
movement_location_t movement_location;
@@ -87,7 +87,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
watch_clear_colon();
watch_clear_indicator(WATCH_INDICATOR_PM);
watch_clear_indicator(WATCH_INDICATOR_24H);
sprintf(buf, "%s%2d none ", (result == 1) ? "SE" : "rI", scratch_time.unit.day);
snprintf(buf, sizeof(buf), "%s%2d none ", (result == 1) ? "SE" : "rI", scratch_time.unit.day);
watch_display_string(buf, 0);
return;
}
@@ -120,7 +120,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
} else if (settings->bit.clock_24h_leading_zero && scratch_time.unit.hour < 10) {
set_leading_zero = true;
}
sprintf(buf, "rI%2d%2d%02d%s", scratch_time.unit.day, scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
snprintf(buf, sizeof(buf), "rI%2d%2d%02d%s", scratch_time.unit.day, scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
watch_display_string(buf, 0);
if (set_leading_zero)
watch_display_string("0", 4);
@@ -152,7 +152,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
} else if (settings->bit.clock_24h_leading_zero && scratch_time.unit.hour < 10) {
set_leading_zero = true;
}
sprintf(buf, "SE%2d%2d%02d%s", scratch_time.unit.day, scratch_time.unit.hour, scratch_time.unit.minute, longLatPresets[state->longLatToUse].name);
snprintf(buf, sizeof(buf), "SE%2d%2d%02d%s", scratch_time.unit.day, scratch_time.unit.hour, scratch_time.unit.minute, longLatPresets[state->longLatToUse].name);
watch_display_string(buf, 0);
if (set_leading_zero)
watch_display_string("0", 4);
@@ -212,16 +212,16 @@ static void _sunrise_sunset_face_update_location_register(sunrise_sunset_state_t
}
static void _sunrise_sunset_face_update_settings_display(movement_event_t event, sunrise_sunset_state_t *state) {
char buf[12];
char buf[11];
switch (state->page) {
case 0:
return;
case 1:
sprintf(buf, "LA %c %04d", state->working_latitude.sign ? '-' : '+', abs(_sunrise_sunset_face_latlon_from_struct(state->working_latitude)));
snprintf(buf, sizeof(buf), "LA %c %04d", state->working_latitude.sign ? '-' : '+', abs(_sunrise_sunset_face_latlon_from_struct(state->working_latitude)));
break;
case 2:
sprintf(buf, "LO %c%05d", state->working_longitude.sign ? '-' : '+', abs(_sunrise_sunset_face_latlon_from_struct(state->working_longitude)));
snprintf(buf, sizeof(buf), "LO %c%05d", state->working_longitude.sign ? '-' : '+', abs(_sunrise_sunset_face_latlon_from_struct(state->working_longitude)));
break;
}
if (event.subsecond % 2) {