summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-store.c
Commit message (Collapse)AuthorAgeFilesLines
* store: Fix use after free with hash table keysKalev Lember2017-01-271-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AsStore keeps a priv->hash_id hash table with app ID's as keys and a GPtrArray with the actual apps matching the app ID as values. To optimize memory use, the keys are all AsRefStrings. As all AsRefStrings are reference counted, they may get freed when the last app with the matching ID gets removed. To handle that case, make sure the remove the GPtrArray holding the apps as well when removing last app matching an ID. This fixes the following use after free when starting gnome-software: ==6065== Invalid read of size 1 ==6065== at 0x8E26650: __strcmp_sse2_unaligned (in /usr/lib64/libc-2.24.so) ==6065== by 0x8585678: g_str_equal (ghash.c:1846) ==6065== by 0x8584BDF: g_hash_table_lookup_node (ghash.c:396) ==6065== by 0x8584BDF: g_hash_table_lookup (ghash.c:1147) ==6065== by 0x4E789F2: as_store_add_app (as-store.c:1229) ==6065== by 0x4E797CA: as_store_from_root (as-store.c:1537) ==6065== by 0x4E7A71F: as_store_from_file_internal (as-store.c:1880) ==6065== by 0x4E7B7A9: as_store_load_app_info_file (as-store.c:2556) ==6065== by 0x4E7B9B8: as_store_load_app_info (as-store.c:2611) ==6065== by 0x4E7C352: as_store_search_app_info (as-store.c:2847) ==6065== by 0x4E7C598: as_store_search_per_system (as-store.c:2883) ==6065== by 0x4E7CF7F: as_store_load (as-store.c:3068) ==6065== by 0x1E512B7B: gs_plugin_setup (gs-plugin-appstream.c:255) ==6065== by 0x46A2C5: gs_plugin_loader_setup (gs-plugin-loader.c:3912) ==6065== by 0x46ECCE: gs_application_initialize_plugins (gs-application.c:228) ==6065== by 0x46ED99: gs_application_dbus_register (gs-application.c:249) ==6065== by 0x8007167: g_application_impl_attempt_primary (gapplicationimpl-dbus.c:406) ==6065== by 0x8007167: g_application_impl_register (gapplicationimpl-dbus.c:555) ==6065== by 0x8003F22: g_application_register (gapplication.c:2033) ==6065== by 0x47064D: gs_application_handle_local_options (gs-application.c:864) ==6065== by 0xEFCFC57: ffi_call_unix64 (unix64.S:76) ==6065== by 0xEFCF6B9: ffi_call (ffi64.c:525) ==6065== Address 0x259c1994 is 4 bytes inside a block of size 31 free'd ==6065== at 0x4C2ED4A: free (vg_replace_malloc.c:530) ==6065== by 0x859B6BD: g_free (gmem.c:189) ==6065== by 0x4E70A37: as_ref_string_unref_from_str (as-ref-string.c:48) ==6065== by 0x8583D22: g_hash_table_remove_node (ghash.c:455) ==6065== by 0x8584647: g_hash_table_remove_internal (ghash.c:1358) ==6065== by 0x4E70E09: as_ref_string_unref (as-ref-string.c:225) ==6065== by 0x4E510B4: as_app_finalize (as-app.c:473) ==6065== by 0x830E116: g_object_unref (gobject.c:3185) ==6065== by 0x8569E2D: g_ptr_array_remove_index (garray.c:1188) ==6065== by 0x856A230: g_ptr_array_remove (garray.c:1321) ==6065== by 0x4E77D49: as_store_remove_app (as-store.c:931) ==6065== by 0x4E789DB: as_store_add_app (as-store.c:1225) ==6065== by 0x4E797CA: as_store_from_root (as-store.c:1537) ==6065== by 0x4E7A71F: as_store_from_file_internal (as-store.c:1880) ==6065== by 0x4E7B7A9: as_store_load_app_info_file (as-store.c:2556) ==6065== by 0x4E7B9B8: as_store_load_app_info (as-store.c:2611) ==6065== by 0x4E7C352: as_store_search_app_info (as-store.c:2847) ==6065== by 0x4E7C598: as_store_search_per_system (as-store.c:2883) ==6065== by 0x4E7CF7F: as_store_load (as-store.c:3068) ==6065== by 0x1E512B7B: gs_plugin_setup (gs-plugin-appstream.c:255) ==6065== Block was alloc'd at ==6065== at 0x4C2DB9D: malloc (vg_replace_malloc.c:299) ==6065== by 0x859B5A8: g_malloc (gmem.c:94) ==6065== by 0x4E70ABF: as_ref_string_new_copy_with_length (as-ref-string.c:99) ==6065== by 0x4E6B908: as_node_reflow_text (as-node.c:516) ==6065== by 0x4E6BEF7: as_node_text_cb (as-node.c:707) ==6065== by 0x859A14D: g_markup_parse_context_parse (gmarkup.c:1514) ==6065== by 0x4E6C29C: as_node_from_xml (as-node.c:825) ==6065== by 0x4E5BAA8: as_app_parse_appdata_file (as-app.c:5665) ==6065== by 0x4E5BE6A: as_app_parse_file (as-app.c:5781) ==6065== by 0x4E7BEDB: as_store_load_installed (as-store.c:2743) ==6065== by 0x4E7C24B: as_store_search_installed (as-store.c:2825) ==6065== by 0x4E7C636: as_store_search_per_system (as-store.c:2890) ==6065== by 0x4E7CF7F: as_store_load (as-store.c:3068) ==6065== by 0x1E512B7B: gs_plugin_setup (gs-plugin-appstream.c:255) ==6065== by 0x46A2C5: gs_plugin_loader_setup (gs-plugin-loader.c:3912) ==6065== by 0x46ECCE: gs_application_initialize_plugins (gs-application.c:228) ==6065== by 0x46ED99: gs_application_dbus_register (gs-application.c:249) ==6065== by 0x8007167: g_application_impl_attempt_primary (gapplicationimpl-dbus.c:406) ==6065== by 0x8007167: g_application_impl_register (gapplicationimpl-dbus.c:555) ==6065== by 0x8003F22: g_application_register (gapplication.c:2033) ==6065== by 0x47064D: gs_application_handle_local_options (gs-application.c:864)
* trivial: Update app ID rename listKalev Lember2017-01-271-0/+22
|
* AsStore: hold a ref in hash_unique_id to avoid use-after-free (#149)Simon McVittie2017-01-261-2/+2
| | | | | | | | | | If we rely on the reference here being "borrowed" from priv->array, then it's easy for that assumption to become unjustified. This caused a crash for me in as_store_remove_app_by_id, which removes the app from priv->array before it removes it from priv->hash_unique_id; if no other code is holding a ref to the same app, then as_app_get_unique_id() will be a use-after-free. Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Do not ignore type=replace merge componentsRichard Hughes2017-01-121-1/+1
|
* trivial: Add yakuake.desktop to rename listKalev Lember2017-01-051-0/+1
|
* trivial: Add some asserts to shut up clangRichard Hughes2016-12-151-0/+7
|
* Subsume the AppData releases into AppStream itemsRichard Hughes2016-12-151-0/+2
| | | | | This preserves the 'installed' state of the AsRelease which gnome-software is using for the update description logic.
* Add Geary to the app id fallbacks (#141)Niels De Graef2016-12-091-0/+1
| | | | | Geary recently renamed its app id to follow flatpak conventions. Adding a fallback to appstream. More info, see [bug 766196](https://bugzilla.gnome.org/show_bug.cgi?id=766196) on GNOME bugzilla.
* Add support for ONLY_NATIVE_LANGS when parsing yaml filesRichard Hughes2016-11-211-1/+4
| | | | This saves ~20Mb of RSS on a typical desktop Debian install.
* Cache the stemmer results in a hash tableRichard Hughes2016-11-211-2/+2
| | | | This reduces the time it takes to populate the token cache by 60%.
* Use refcounted strings in all objectsRichard Hughes2016-11-211-6/+18
| | | | | This drops the RSS by ~1Mb and has the potential to do much more drastic things if this is used in GNOME Software.
* trivial: Remove two unused variablesKalev Lember2016-11-071-1/+0
|
* trivial: Restore behaviour compatibility to fix self testsRichard Hughes2016-11-041-0/+1
|
* Allow the client to control what search fields are indexedRichard Hughes2016-11-031-0/+19
| | | | | | | This can be used to improve load speed in GNOME Software. By default everything is indexed, which includes the multi-paragraph long description. Omitting this information makes a huge difference to the creation time of the search token cache.
* trivial: Only load native languages from desktop files when the flag is setRichard Hughes2016-11-031-0/+4
| | | | This saves 40ms from the AsStore startup time.
* Only load native languages when parsing AppStream dataRichard Hughes2016-11-031-7/+10
| | | | | | | This adds an optional flag that allows the node parser to ignore any nodes that do not match the native languages of the user. This increases startup speed of gnome-software by ~40ms but also drops the RSS by a massive 12Mb for the Fedora AppStream file.
* trivial: Show threaded tasks in bold in the profile outputRichard Hughes2016-11-021-1/+1
|
* Use multiple threads to load the search cacheRichard Hughes2016-11-021-3/+15
| | | | This speeds up loading the token cache by 30ms on x64.
* Load the search token blacklist into a hash tableRichard Hughes2016-11-021-0/+37
| | | | This speeds up loading the token cache by 55ms on x64 and a lot more on ARM.
* trivial: Unsingleton AsStemmer and use a shared instance in AsStoreRichard Hughes2016-11-021-0/+7
| | | | This allows us to test the stemming functionality with different locales.
* Add as_store_load_search_cache()Richard Hughes2016-11-021-0/+32
| | | | This is really only useful for profiling startup speed.
* Add app-removed, app-added and app-changed signals to AsStoreRichard Hughes2016-10-311-1/+67
| | | | This allows us to invalidate things built from the AsApp objects.
* Always copy the installed state when replacing AppData with AppStreamRichard Hughes2016-10-191-0/+2
| | | | This only appears to happen on Debian for some reason.
* Ensure the component scope is set when loading yaml filesRichard Hughes2016-10-191-3/+9
|
* Revert "trivial: Restrict the bundle kind when parsing local files"Richard Hughes2016-10-191-7/+0
| | | | | | | | This reverts commit 9b36119e1ed8ae7c2bec341143c343a9d73dcdd8 as it causes a crash in gnome-software 3-22 when a component is available locally as an addon but not in the appstream yaml or xml files. The commit is clearly wrong, I guess the original author was crazy.
* Monitor missing AppStream directoriesRichard Hughes2016-10-191-42/+40
| | | | | | | Monitor some locations so that if they are created after the AsStore is loaded we correctly detect and load the new AppStream XML files Inspired by a patch by Joaquim Rocha <jrocha@endlessm.com>, many thanks.
* Allow filtering applications based on merge typeRichard Hughes2016-10-121-1/+18
| | | | | This allows us to load only merge-type components, which we might want when sharing per-system or per-user overrides.
* Add flag to only load uncompressed files into a storeRichard Hughes2016-10-121-0/+8
| | | | Sometimes we just want the 'extra' files rather than the distro-supplied ones.
* Fix a small memory leak when parsing yaml filesRichard Hughes2016-09-281-3/+3
|
* Fix setting the origin for Flatpak user reposwip/jrocha/fix-user-reposJoaquim Rocha2016-09-271-1/+1
| | | | | | | | | | The origin was being stripped the first 8 characters so it would discard the "flatpak:" prefix. However, when on a user installation the prefix is "user-flatpak:" so the origin would erroneously be set to "tpak:gnome-apps". These changes discard the completely profile after checking for the prefix's delimiter.
* trivial: Allow detailed profiling when using as_store_from_file()Richard Hughes2016-09-141-8/+5
|
* Add as_store_add_apps()Richard Hughes2016-09-131-0/+31
| | | | This allows us to add lots of apps without issuing a 'changed' signal for each.
* Convert the built unknown icons to the correct kind depending on the actionRichard Hughes2016-09-051-0/+10
| | | | | | For building we want ->CACHED, for parsing local files we want ->STOCK. Fixes the other half of https://github.com/hughsie/appstream-glib/pull/128
* Support components with merge=replace rulesRichard Hughes2016-09-021-9/+19
| | | | This allows components to replace parts of the app without just appending.
* Ignore system datadirs that are actually per-userRichard Hughes2016-08-251-0/+4
| | | | When running in jhbuild this is somehow set incorrectly.
* trivial: Don't show some applications as installed when they are notRichard Hughes2016-08-251-2/+4
| | | | Only deduplicate AppStream::AppData when the appdata file has system scope.
* trivial: Restrict the bundle kind when parsing local filesRichard Hughes2016-08-231-0/+7
| | | | This means we don't wildcard match against user non-package apps.
* trivial: Restrict the scope when parsing local filesRichard Hughes2016-08-231-0/+1
| | | | This means we don't wildcard match against user non-package apps.
* trivial: Fix a small memory leak in AsStoreRichard Hughes2016-08-181-1/+1
|
* Support AppStream merge componentsRichard Hughes2016-08-111-1/+6
| | | | These are components that should be merged into matching entries.
* trivial: Allow setting the output trusted mode using an environment variableRichard Hughes2016-08-101-0/+6
|
* Allow subsuming each property individuallyRichard Hughes2016-08-091-5/+10
| | | | This allows us to define a safe sane subset for merging and dedupe.
* Don't include the architecture in the unique IDRichard Hughes2016-08-091-5/+3
| | | | These are the same 'app' to the end user.
* Don't include the version in the unique IDRichard Hughes2016-08-091-3/+1
| | | | We have releases; different versions should be merged.
* Only subsume a safe subset from merge componentsRichard Hughes2016-08-051-2/+4
| | | | | We certainly don't want to copy over the source file, origin, branch or version from the merged application.
* trivial: Parse the unique_id correctly when searchingRichard Hughes2016-08-051-4/+4
|
* trivial: Use the existing quirk as it can be made useful againRichard Hughes2016-08-051-2/+2
|
* Use a more relaxed unique-id match for merge componentsRichard Hughes2016-08-051-1/+6
|
* Support merge componentsRichard Hughes2016-08-041-0/+61
| | | | | This allows us to match soon-to-be-specified merge components to every component in the store.
* Always use wildcards when adding apps to the storeRichard Hughes2016-08-031-36/+19
| | | | | | | It's never right to do an explicit check; if we add a system-wide AppStream web-app and then a per-user .desktop version we actually want them to match. The same is true for a per-system app with a per-user override.