Blame SOURCES/place_rank-crasher.patch

fad84f
From 24d842347a294fe19393f95c3ce98cc5de9bcabe Mon Sep 17 00:00:00 2001
fad84f
From: Bastien Nocera <hadess@hadess.net>
fad84f
Date: Thu, 14 Mar 2019 01:22:39 +0100
fad84f
Subject: [PATCH 1/3] tests: Add test for issue #6
fad84f
fad84f
---
fad84f
 geocode-glib/tests/geocode-glib.c            | 1 +
fad84f
 geocode-glib/tests/meson.build               | 1 +
fad84f
 geocode-glib/tests/nominatim-place_rank.json | 1 +
fad84f
 3 files changed, 3 insertions(+)
fad84f
 create mode 100644 geocode-glib/tests/nominatim-place_rank.json
fad84f
fad84f
diff --git a/geocode-glib/tests/geocode-glib.c b/geocode-glib/tests/geocode-glib.c
fad84f
index 5da23e5..e7d6d84 100644
fad84f
--- a/geocode-glib/tests/geocode-glib.c
fad84f
+++ b/geocode-glib/tests/geocode-glib.c
fad84f
@@ -789,6 +789,7 @@ test_resolve_json (void)
fad84f
 		{ "nominatim-area.json", 1, NULL, "area", "Guildford Park" },
fad84f
 		{ "nominatim-no-results.json", 1, "No matches found for request", NULL, NULL },
fad84f
 		{ "nominatim-data-type-change.json", 12, NULL, "osm_id", "335673748" },
fad84f
+		{ "nominatim-place_rank.json", 10, NULL, "osm_id", "2555133" },
fad84f
 	};
fad84f
 
fad84f
 	for (i = 0; i < G_N_ELEMENTS (tests); i++) {
fad84f
diff --git a/geocode-glib/tests/meson.build b/geocode-glib/tests/meson.build
fad84f
index 61df92c..59a065c 100644
fad84f
--- a/geocode-glib/tests/meson.build
fad84f
+++ b/geocode-glib/tests/meson.build
fad84f
@@ -28,6 +28,7 @@ install_data('locale_format.json',
fad84f
              'locale_name.json',
fad84f
              'nominatim-area.json',
fad84f
              'nominatim-no-results.json',
fad84f
+             'nominatim-place_rank.json',
fad84f
              'nominatim-rio.json',
fad84f
              'osm_type0.json',
fad84f
              'osm_type1.json',
fad84f
diff --git a/geocode-glib/tests/nominatim-place_rank.json b/geocode-glib/tests/nominatim-place_rank.json
fad84f
new file mode 100644
fad84f
index 0000000..bb5f008
fad84f
--- /dev/null
fad84f
+++ b/geocode-glib/tests/nominatim-place_rank.json
fad84f
@@ -0,0 +1 @@
fad84f
+[{"place_id":"159575959","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"2555133","boundingbox":["55.4913076","55.9574097","37.290502","37.9674277"],"lat":"55.7506828","lon":"37.6174976","display_name":"Moskva, Центральный административный округ, Moskva, Centrální federální okruh, Ruská federace","category":"place","type":"city","importance":0.81231629038453,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_city.p.20.png","address":{"city":"Moskva","state_district":"Центральный административный округ","state":"Moskva","country":"Ruská federace","country_code":"ru"}},{"place_id":"159148837","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"102269","boundingbox":["55.1421745","56.0212238","36.8031012","37.9674277"],"lat":"55.4792046","lon":"37.3273304","display_name":"Moskva, Centrální federální okruh, Ruská federace","category":"boundary","type":"administrative","importance":0.81231629038453,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_boundary_administrative.p.20.png","address":{"state":"Moskva","country":"Ruská federace","country_code":"ru"}},{"place_id":"158661492","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"121430","boundingbox":["46.710912","46.758882","-117.0396979","-116.9620679"],"lat":"46.7323875","lon":"-117.000165","display_name":"Moscow, Latah County, Idaho, Spojené státy americké","category":"place","type":"city","importance":0.53629964602682,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_city.p.20.png","address":{"city":"Moscow","county":"Latah County","state":"Idaho","country":"Spojené státy americké","country_code":"us"}},{"place_id":"83209933","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"87186419","boundingbox":["25.2302669","25.2325261","55.1643501","55.1667109"],"lat":"25.2313998","lon":"55.1655538746233","display_name":"Moscow, Dubaj, دبي‎, Spojené arabské emiráty","category":"place","type":"island","importance":0.425,"address":{"island":"Moscow","city":"Dubaj","state":"دبي‎","country":"Spojené arabské emiráty","country_code":"ae"}},{"place_id":"158830575","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"188588","boundingbox":["41.332327","41.359539","-75.5571869","-75.5055579"],"lat":"41.3367497","lon":"-75.518519","display_name":"Moscow, Lackawanna County, Pensylvánie, Spojené státy americké","category":"boundary","type":"administrative","importance":0.40496966945241,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_boundary_administrative.p.20.png","address":{"city":"Moscow","county":"Lackawanna County","state":"Pensylvánie","country":"Spojené státy americké","country_code":"us"}},{"place_id":"453497","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"node","osm_id":"157606151","boundingbox":["39.5237014","39.5637014","-79.0250272","-78.9850272"],"lat":"39.5437014","lon":"-79.0050272","display_name":"Moscow, Allegany County, Maryland, Spojené státy americké","category":"place","type":"hamlet","importance":0.37594331946278,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_village.p.20.png","address":{"hamlet":"Moscow","county":"Allegany County","state":"Maryland","country":"Spojené státy americké","country_code":"us"}},{"place_id":"421984","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"node","osm_id":"153805006","boundingbox":["37.3914401","37.4314401","-89.0725736","-89.0325736"],"lat":"37.4114401","lon":"-89.0525736","display_name":"Moscow, Union County, Illinois, Spojené státy americké","category":"place","type":"hamlet","importance":0.375,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_village.p.20.png","address":{"hamlet":"Moscow","county":"Union County","state":"Illinois","country":"Spojené státy americké","country_code":"us"}},{"place_id":"436343","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"node","osm_id":"154194549","boundingbox":["42.0302346","42.0702346","-84.5298798","-84.4898798"],"lat":"42.0502346","lon":"-84.5098798","display_name":"Moscow, Hillsdale County, Michigan, Spojené státy americké","category":"place","type":"village","importance":0.375,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_village.p.20.png","address":{"village":"Moscow","county":"Hillsdale County","state":"Michigan","country":"Spojené státy americké","country_code":"us"}},{"place_id":"390992","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"node","osm_id":"151964024","boundingbox":["43.6871833","43.7271833","-93.1182537","-93.0782537"],"lat":"43.7071833","lon":"-93.0982537","display_name":"Moscow, Freeborn County, Minnesota, Spojené státy americké","category":"place","type":"village","importance":0.375,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_village.p.20.png","address":{"village":"Moscow","county":"Freeborn County","state":"Minnesota","country":"Spojené státy americké","country_code":"us"}},{"place_id":"377384","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"node","osm_id":"151724752","boundingbox":["39.1463923","39.1863923","-94.5618989","-94.5218989"],"lat":"39.1663923","lon":"-94.5418989","display_name":"Moscow, Clay County, Missouri, Spojené státy americké","category":"place","type":"hamlet","importance":0.375,"icon":"https:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_village.p.20.png","address":{"hamlet":"Moscow","county":"Clay County","state":"Missouri","country":"Spojené státy americké","country_code":"us"}}]
fad84f
-- 
fad84f
2.26.0
fad84f
fad84f
fad84f
From e7216583a219df9d9eba21a7fe1b74543b6d5851 Mon Sep 17 00:00:00 2001
fad84f
From: Bastien Nocera <hadess@hadess.net>
fad84f
Date: Thu, 14 Mar 2019 01:23:19 +0100
fad84f
Subject: [PATCH 2/3] geocode-nominatim: Fix possible crash with missing
fad84f
 place_rank
fad84f
fad84f
Spotted by Ordissimo <thierry@ordissimo.com>
fad84f
fad84f
Closes: #6
fad84f
---
fad84f
 geocode-glib/geocode-nominatim.c | 4 +++-
fad84f
 1 file changed, 3 insertions(+), 1 deletion(-)
fad84f
fad84f
diff --git a/geocode-glib/geocode-nominatim.c b/geocode-glib/geocode-nominatim.c
fad84f
index b2abc97..fc333dc 100644
fad84f
--- a/geocode-glib/geocode-nominatim.c
fad84f
+++ b/geocode-glib/geocode-nominatim.c
fad84f
@@ -390,9 +390,11 @@ get_place_type_from_attributes (GHashTable *ht)
fad84f
                 place_type =  GEOCODE_PLACE_TYPE_DRAINAGE;
fad84f
         } else if (g_strcmp0 (category, "boundary") == 0) {
fad84f
                 if (g_strcmp0 (type, "administrative") == 0) {
fad84f
+                        const char *place_rank;
fad84f
                         int rank;
fad84f
 
fad84f
-                        rank = atoi (g_hash_table_lookup (ht, "place_rank"));
fad84f
+                        place_rank = g_hash_table_lookup (ht, "place_rank");
fad84f
+                        rank = place_rank ? atoi (place_rank) : 0;
fad84f
                         if (rank < 2)
fad84f
                                 place_type =  GEOCODE_PLACE_TYPE_UNKNOWN;
fad84f
 
fad84f
-- 
fad84f
2.26.0
fad84f
fad84f
fad84f
From 0d4f1bad55121dd70f38f68d64ea7d755634ebf1 Mon Sep 17 00:00:00 2001
fad84f
From: Bastien Nocera <hadess@hadess.net>
fad84f
Date: Thu, 14 Mar 2019 01:24:13 +0100
fad84f
Subject: [PATCH 3/3] tests: Fix missing installed-tests file
fad84f
fad84f
---
fad84f
 geocode-glib/tests/meson.build | 1 +
fad84f
 1 file changed, 1 insertion(+)
fad84f
fad84f
diff --git a/geocode-glib/tests/meson.build b/geocode-glib/tests/meson.build
fad84f
index 59a065c..a64baaa 100644
fad84f
--- a/geocode-glib/tests/meson.build
fad84f
+++ b/geocode-glib/tests/meson.build
fad84f
@@ -27,6 +27,7 @@ test('Test mock backend', e)
fad84f
 install_data('locale_format.json',
fad84f
              'locale_name.json',
fad84f
              'nominatim-area.json',
fad84f
+             'nominatim-data-type-change.json',
fad84f
              'nominatim-no-results.json',
fad84f
              'nominatim-place_rank.json',
fad84f
              'nominatim-rio.json',
fad84f
-- 
fad84f
2.26.0
fad84f