From: Dodji Seketeli Date: Wed, 26 Apr 2023 20:19:35 +0000 (+0200) Subject: ini: Do not crash on incorrect property value X-Git-Tag: upstream/2.3~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1392a720a862c27a7ef4e9b5b9e40253693e336d;p=platform%2Fupstream%2Flibabigail.git ini: Do not crash on incorrect property value When the value of the 'name_regexp' property is incorrect, the ini parser can crash. Pancake, of Radare2 fame, reported this one by email. Fixed thus. * src/abg-ini.cc (read_context::read_property_value): Do not dereference a null pointer to list property value. * tests/data/test-ini/test02-buggy-property-value.abignore: New test input. * tests/data/test-ini/test02-buggy-property-value.abignore.expected: Likewise. * tests/data/Makefile.am: Add the two new test inputs to source distribution. * tests/test-ini.cc (in_out_spec): Add the new test input pair to this test harness. Signed-off-by: Dodji Seketeli --- diff --git a/src/abg-ini.cc b/src/abg-ini.cc index db041962..830b3ab8 100644 --- a/src/abg-ini.cc +++ b/src/abg-ini.cc @@ -1353,7 +1353,7 @@ public: } list_property_value_sptr list = read_list_property_value(); - if (list->get_content().size() == 1) + if (list && list->get_content().size() == 1) result.reset(new string_property_value(list->get_content()[0])); else result = list; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 4c472697..ce791ad4 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -2328,6 +2328,8 @@ test-fedabipkgdiff/nss-util/nss-util-3.24.0-2.0.fc25.x86_64.rpm \ \ test-ini/test01-equal-in-property-string.abignore.expected \ test-ini/test01-equal-in-property-string.abignore \ +test-ini/test02-buggy-property-value.abignore \ +test-ini/test02-buggy-property-value.abignore.expected \ \ test-kmi-whitelist/whitelist-with-single-entry \ test-kmi-whitelist/whitelist-with-another-single-entry \ diff --git a/tests/data/test-ini/test02-buggy-property-value.abignore b/tests/data/test-ini/test02-buggy-property-value.abignore new file mode 100644 index 00000000..de1f1eb2 --- /dev/null +++ b/tests/data/test-ini/test02-buggy-property-value.abignore @@ -0,0 +1,2 @@ +[suppress_function] + name_regexp = [ \ No newline at end of file diff --git a/tests/data/test-ini/test02-buggy-property-value.abignore.expected b/tests/data/test-ini/test02-buggy-property-value.abignore.expected new file mode 100644 index 00000000..e69de29b diff --git a/tests/test-ini.cc b/tests/test-ini.cc index 24968e8c..9676acf2 100644 --- a/tests/test-ini.cc +++ b/tests/test-ini.cc @@ -48,6 +48,12 @@ InOutSpec in_out_specs[] = "output/test-ini/test01-equal-in-property-string.abignore", "" } + { + "data/test-ini/test02-buggy-property-value.abignore", + "data/test-ini/test02-buggy-property-value.abignore.expected", + "output/test-ini/test02-buggy-property-value.abignore", + "" + } , // This one must always remain the last one. {0, 0, 0, 0}