]> git.earman.xyz Git - sensor-watch.git/commitdiff
Fix text buffer overflow in sunrise_sunset_face (#22)
authorPrimmR <primmr@icloud.com>
Sun, 6 Jul 2025 15:31:45 +0000 (16:31 +0100)
committerGitHub <noreply@github.com>
Sun, 6 Jul 2025 15:31:45 +0000 (11:31 -0400)
watch-faces/complication/sunrise_sunset_face.c
watch-faces/complication/sunrise_sunset_face.h

index f503a5a2fcdfe49e0cc54ce0ae5c2d705341257e..7dcb33506229508660b3d0d494ba44eec47dee14 100644 (file)
@@ -152,7 +152,7 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
                 watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "RIS", "rI");
                 sprintf(buf, "%2d", scratch_time.unit.day);
                 watch_display_text(WATCH_POSITION_TOP_RIGHT, buf);
-                sprintf(buf, "%2d%02d%s", scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
+                sprintf(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 {
@@ -191,7 +191,7 @@ static void _sunrise_sunset_face_update(sunrise_sunset_state_t *state) {
                 watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "SET", "SE");
                 sprintf(buf, "%2d", scratch_time.unit.day);
                 watch_display_text(WATCH_POSITION_TOP_RIGHT, buf);
-                sprintf(buf, "%2d%02d%s", scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
+                sprintf(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 {
index 9ba37a5446147077989cb3b900aed140570de71e..b4bded0c0c4c71d0f936a39c16f493f7a3bd2c72 100644 (file)
@@ -72,7 +72,7 @@ void sunrise_sunset_face_resign(void *context);
 })
 
 typedef struct {
-    char name[2];
+    char name[3];
     int16_t latitude;
     int16_t longitude;
 } long_lat_presets_t;