summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornate <nate@metis>2026-02-25 11:31:54 -0800
committerVictor Kareh <[email protected]>2026-02-25 16:41:50 -0500
commitee3f3e2e816f4425df2a33ca3255764d8139f5c4 (patch)
treea455272c4c06ad70100750880e5b8f2121a181b2
parent60cde2ba0f24946272e925c352129fcad18a7c4f (diff)
downloadlibmateweather-ee3f3e2e816f4425df2a33ca3255764d8139f5c4.tar.bz2
libmateweather-ee3f3e2e816f4425df2a33ca3255764d8139f5c4.tar.xz
metar: fix pointer offset in metar_finish
The pointer offset for the `METAR/SPECI` search key is 6 characters too short. The search key is now `<raw_text>METAR KPDX` (21 chars), but the code still advances by 15 characters, which was correct for the old format `<raw_text>KPDX` This lands the pointer on `KPDX 161753Z...` instead of `161753Z...`. The regex parser skips the unrecognized tokens so it often still works, but it passes garbage to metar_parse and could cause subtle parser failures.
-rw-r--r--libmateweather/weather-metar.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libmateweather/weather-metar.c b/libmateweather/weather-metar.c
index d25a432..d638096 100644
--- a/libmateweather/weather-metar.c
+++ b/libmateweather/weather-metar.c
@@ -536,7 +536,10 @@ metar_finish (GObject *source, GAsyncResult *result, gpointer data)
}
if (p) {
- p += WEATHER_LOCATION_CODE_LEN + 11;
+ p += strlen (searchkey) + 1;
+ }
+ g_free (searchkey);
+ if (p) {
endtag = xstrnstr (p, end - p, "</raw_text>");
if (endtag)
metar = g_strndup (p, endtag - p);
@@ -544,10 +547,7 @@ metar_finish (GObject *source, GAsyncResult *result, gpointer data)
metar = g_strndup (p, end - p);
success = metar_parse (metar, info);
g_free (metar);
- }
- g_free (searchkey);
-
- if (!success && !xstrnstr (response_body, len, "aviationweather.gov")) {
+ } else if (!xstrnstr (response_body, len, "aviationweather.gov")) {
/* The response doesn't even seem to have come from NOAA...
* most likely it is a wifi hotspot login page. Call that a
* network error.