From b1b86b28786572111ba130f7c0bf1399c66c11ca Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 3 Feb 2025 18:37:50 +0100 Subject: [PATCH] Resolves: RHEL-4090 (Fix Nominatim crasher) --- 0001-fix-nominatim-crasher.patch | 102 +++++++++++++++++++++++++++++++ geocode-glib.spec | 9 ++- 2 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 0001-fix-nominatim-crasher.patch diff --git a/0001-fix-nominatim-crasher.patch b/0001-fix-nominatim-crasher.patch new file mode 100644 index 0000000..e52ce09 --- /dev/null +++ b/0001-fix-nominatim-crasher.patch @@ -0,0 +1,102 @@ +From e1a6b067dc42618992787e84aadad2ca27ae0017 Mon Sep 17 00:00:00 2001 +From: Marcus Lundblad +Date: Sun, 10 Mar 2019 22:59:53 +0100 +Subject: [PATCH 1/2] geocode-nominatim: Fix parsing of integer JSON values + +It seems Nominatim has changed to (sometimes) use integer +values for certain values (such as osm_id and rank) instead +of strings as it was always before. + +Closes: #5 +--- + geocode-glib/geocode-nominatim.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/geocode-glib/geocode-nominatim.c b/geocode-glib/geocode-nominatim.c +index c1f6bc7..b2abc97 100644 +--- a/geocode-glib/geocode-nominatim.c ++++ b/geocode-glib/geocode-nominatim.c +@@ -1063,21 +1063,24 @@ _geocode_read_nominatim_attributes (JsonReader *reader, + } + + for (i = 0; members[i] != NULL; i++) { +- const char *value = NULL; ++ char *value = NULL; + + json_reader_read_member (reader, members[i]); + + if (json_reader_is_value (reader)) { + JsonNode *node = json_reader_get_value (reader); + if (json_node_get_value_type (node) == G_TYPE_STRING) { +- value = json_node_get_string (node); ++ value = g_strdup (json_node_get_string (node)); + if (value && *value == '\0') +- value = NULL; ++ g_clear_pointer (&value, g_free); ++ } else if (json_node_get_value_type (node) == G_TYPE_INT64) { ++ gint64 int_value = json_node_get_int (node); ++ value = g_strdup_printf ("%" G_GINT64_FORMAT, int_value); + } + } + + if (value != NULL) { +- g_hash_table_insert (ht, g_strdup (members[i]), g_strdup (value)); ++ g_hash_table_insert (ht, g_strdup (members[i]), value); + + if (i == 0 && is_address) { + if (g_strcmp0 (members[i], "house_number") != 0) +-- +GitLab + + +From ada95229ab54143f894befe1f1bb911a8cf2ccbc Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +Date: Tue, 12 Mar 2019 13:46:35 +0100 +Subject: [PATCH 2/2] tests: Add test for issue #5 + +--- + geocode-glib/tests/geocode-glib.c | 8 +++++--- + geocode-glib/tests/nominatim-data-type-change.json | 1 + + 2 files changed, 6 insertions(+), 3 deletions(-) + create mode 100644 geocode-glib/tests/nominatim-data-type-change.json + +diff --git a/geocode-glib/tests/geocode-glib.c b/geocode-glib/tests/geocode-glib.c +index ce26b3d..5da23e5 100644 +--- a/geocode-glib/tests/geocode-glib.c ++++ b/geocode-glib/tests/geocode-glib.c +@@ -781,12 +781,14 @@ test_resolve_json (void) + guint i; + struct { + const char *fname; ++ guint num_results; + const char *error; + const char *prop; + const char *value; + } tests[] = { +- { "nominatim-area.json", NULL, "area", "Guildford Park" }, +- { "nominatim-no-results.json", "No matches found for request", NULL, NULL }, ++ { "nominatim-area.json", 1, NULL, "area", "Guildford Park" }, ++ { "nominatim-no-results.json", 1, "No matches found for request", NULL, NULL }, ++ { "nominatim-data-type-change.json", 12, NULL, "osm_id", "335673748" }, + }; + + for (i = 0; i < G_N_ELEMENTS (tests); i++) { +@@ -811,7 +813,7 @@ test_resolve_json (void) + g_assert_cmpstr (error->message, ==, tests[i].error); + } else { + g_assert (list != NULL); +- g_assert_cmpint (g_list_length (list), ==, 1); ++ g_assert_cmpint (g_list_length (list), ==, tests[i].num_results); + } + + if (list == NULL) { +diff --git a/geocode-glib/tests/nominatim-data-type-change.json b/geocode-glib/tests/nominatim-data-type-change.json +new file mode 100644 +index 0000000..2e68902 +--- /dev/null ++++ b/geocode-glib/tests/nominatim-data-type-change.json +@@ -0,0 +1 @@ ++[{"place_id":1484796,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":335673748,"boundingbox":["60.0684261","60.1084261","17.5353792","17.5753792"],"lat":"60.0884261","lon":"17.5553792","display_name":"Läby, Uppsala kommun, Uppsala län, Svealand, 74372, Sverige","place_rank":19,"category":"place","type":"village","importance":0.41732695533476405,"icon":"https://nominatim.openstreetmap.org/images/mapicons/poi_place_village.p.20.png","address":{"village":"Läby","county":"Uppsala kommun","state":"Uppsala län","postcode":"74372","country":"Sverige","country_code":"se"}},{"place_id":54443946,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":4362794461,"boundingbox":["59.8285267","59.8685267","17.5027922","17.5427922"],"lat":"59.8485267","lon":"17.5227922","display_name":"Läby, Uppsala kommun, Uppsala län, Svealand, 75592, Sverige","place_rank":19,"category":"place","type":"hamlet","importance":0.375,"icon":"https://nominatim.openstreetmap.org/images/mapicons/poi_place_village.p.20.png","address":{"hamlet":"Läby","county":"Uppsala kommun","state":"Uppsala län","postcode":"75592","country":"Sverige","country_code":"se"}},{"place_id":4523898,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":488567113,"boundingbox":["49.600219","49.640219","14.803646","14.843646"],"lat":"49.620219","lon":"14.823646","display_name":"Laby, okres Benešov, Středočeský kraj, Střední Čechy, 25706, Tjeckien","place_rank":19,"category":"place","type":"hamlet","importance":0.275,"icon":"https://nominatim.openstreetmap.org/images/mapicons/poi_place_village.p.20.png","address":{"hamlet":"Laby","county":"okres Benešov","state":"Střední Čechy","postcode":"25706","country":"Tjeckien","country_code":"cz"}},{"place_id":61965574,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":5054371008,"boundingbox":["48.5229788","48.5429788","3.4614936","3.4814936"],"lat":"48.5329788","lon":"3.4714936","display_name":"Laby, Saint-Nicolas-la-Chapelle, Nogent-sur-Seine, Aube, Grand Est, Metropolitan Frankrike, 10400, Frankrike","place_rank":20,"category":"place","type":"locality","importance":0.25,"icon":"https://nominatim.openstreetmap.org/images/mapicons/poi_place_village.p.20.png","address":{"locality":"Laby","village":"Saint-Nicolas-la-Chapelle","county":"Nogent-sur-Seine","state":"Grand Est","country":"Frankrike","postcode":"10400","country_code":"fr"}},{"place_id":678264,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":253146579,"boundingbox":["59.1090262","59.1490262","11.3477701","11.3877701"],"lat":"59.1290262","lon":"11.3677701","display_name":"Låby, Rød, Halden, Østfold, 1781, Norge","place_rank":20,"category":"place","type":"suburb","importance":0.25,"icon":"https://nominatim.openstreetmap.org/images/mapicons/poi_place_village.p.20.png","address":{"suburb":"Låby","hamlet":"Rød","county":"Østfold","postcode":"1781","country":"Norge","country_code":"no"}},{"place_id":198278042,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"relation","osm_id":426449,"boundingbox":["49.6147714","49.6299627","14.8122181","14.8417143"],"lat":"49.6223386","lon":"14.8278537750364","display_name":"Laby, Zvěstov, okres Benešov, Středočeský kraj, Střední Čechy, Tjeckien","place_rank":20,"category":"boundary","type":"administrative","importance":0.25,"icon":"https://nominatim.openstreetmap.org/images/mapicons/poi_boundary_administrative.p.20.png","address":{"suburb":"Laby","village":"Zvěstov","county":"okres Benešov","state":"Střední Čechy","country":"Tjeckien","country_code":"cz"}},{"place_id":252565848,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":6259990008,"boundingbox":["59.3303","59.3503","11.45645","11.47645"],"lat":"59.3403","lon":"11.46645","display_name":"Låby, Nakkjum, Rakkestad, Østfold, 1892, Norge","place_rank":20,"category":"place","type":"farm","importance":0.25,"address":{"farm":"Låby","hamlet":"Nakkjum","county":"Østfold","postcode":"1892","country":"Norge","country_code":"no"}},{"place_id":199085752,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"relation","osm_id":7535162,"boundingbox":["54.0451","54.04999","27.03332","27.04053"],"lat":"54.0479636","lon":"27.0380371","display_name":"Лабы, Раковский сельский Совет, Воложинский район, Минская область, Vitryssland","place_rank":20,"category":"boundary","type":"administrative","importance":0.25,"icon":"https://nominatim.openstreetmap.org/images/mapicons/poi_boundary_administrative.p.20.png","address":{"suburb":"Лабы","city":"Раковский сельский Совет","county":"Воложинский район","state":"Минская область","country":"Vitryssland","country_code":"by"}},{"place_id":26706407,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":2586479869,"boundingbox":["59.848771","59.848871","17.5328345","17.5329345"],"lat":"59.848821","lon":"17.5328845","display_name":"Läby, 72, Kvarnbolund, Kristineberg, Läby, Uppsala kommun, Uppsala län, Svealand, 75592, Sverige","place_rank":30,"category":"highway","type":"bus_stop","importance":0.101,"icon":"https://nominatim.openstreetmap.org/images/mapicons/transport_bus_stop2.p.20.png","address":{"bus_stop":"Läby","road":"72","neighbourhood":"Kvarnbolund","suburb":"Kristineberg","hamlet":"Läby","county":"Uppsala kommun","state":"Uppsala län","postcode":"75592","country":"Sverige","country_code":"se"}},{"place_id":26785299,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":2573658162,"boundingbox":["48.2139118","48.2140118","16.3295261","16.3296261"],"lat":"48.2139618","lon":"16.3295761","display_name":"Laby, Ottakringer Straße, KG Hernals, Ottakring, Wien, 1160, Österrike","place_rank":30,"category":"amenity","type":"cafe","importance":0.001,"icon":"https://nominatim.openstreetmap.org/images/mapicons/food_cafe.p.20.png","address":{"cafe":"Laby","road":"Ottakringer Straße","suburb":"KG Hernals","city_district":"Ottakring","state":"Wien","postcode":"1160","country":"Österrike","country_code":"at"}},{"place_id":5037437,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":564100750,"boundingbox":["49.6242619","49.6243619","14.8187762","14.8188762"],"lat":"49.6243119","lon":"14.8188262","display_name":"Laby, 01816, Bořkovice, Zvěstov, okres Benešov, Středočeský kraj, Střední Čechy, 25706, Tjeckien","place_rank":30,"category":"tourism","type":"information","importance":0.001,"icon":"https://nominatim.openstreetmap.org/images/mapicons/amenity_information.p.20.png","address":{"information":"Laby","road":"01816","suburb":"Bořkovice","village":"Zvěstov","county":"okres Benešov","state":"Střední Čechy","postcode":"25706","country":"Tjeckien","country_code":"cz"}},{"place_id":239522513,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright","osm_type":"node","osm_id":5919537959,"boundingbox":["60.3183959","60.3184959","19.996537","19.996637"],"lat":"60.3184459","lon":"19.996587","display_name":"Laby, Saltviksvägen, Näs, Saltvik, Ålands landsbygd, Landskapet Åland, Regional State Agency Åland, Åland, 22320, Finland","place_rank":30,"category":"highway","type":"bus_stop","importance":0.001,"icon":"https://nominatim.openstreetmap.org/images/mapicons/transport_bus_stop2.p.20.png","address":{"bus_stop":"Laby","road":"Saltviksvägen","suburb":"Näs","village":"Saltvik","county":"Åland","state_district":"Regional State Agency Åland","state":"Åland","postcode":"22320","country":"Finland","country_code":"fi"}}] +-- +GitLab + diff --git a/geocode-glib.spec b/geocode-glib.spec index 9121bbb..86673e5 100644 --- a/geocode-glib.spec +++ b/geocode-glib.spec @@ -2,13 +2,15 @@ Name: geocode-glib Version: 3.26.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Geocoding helper library License: LGPLv2+ URL: http://www.gnome.org/ Source0: http://download.gnome.org/sources/%{name}/3.26/%{name}-%{version}.tar.xz +Patch: 0001-fix-nominatim-crasher.patch + BuildRequires: gettext BuildRequires: gtk-doc BuildRequires: meson @@ -37,7 +39,7 @@ developing applications that use %{name}. %prep -%setup -q +%autosetup -p1 -S gendiff %build @@ -68,6 +70,9 @@ developing applications that use %{name}. %changelog +* Mon Feb 03 2025 Milan Crha - 3.26.0-4 +- Resolves: RHEL-4090 (Fix Nominatim crasher) + * Mon Feb 01 2021 Kalev Lember - 3.26.0-3 - Rebuild against fixed gtk-doc to fix another multilib conflict (#1853142)