diff options
author | Richard Hughes <richard@hughsie.com> | 2016-06-07 11:42:11 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-06-07 11:42:27 +0100 |
commit | 960a6d9d22d6f7756093ffdb5fa46c1b588991e3 (patch) | |
tree | 77bbd79c4021d14c81a62caef95900da57b10478 | |
parent | 9f0bf35993a9469df6448fa751c2888c875e4054 (diff) | |
download | appstream-glib-960a6d9d22d6f7756093ffdb5fa46c1b588991e3.tar.gz |
Never allow NULL to be added to AsApp string array
This is going to make incorrect code produce a critical warning when adding
invalid values, but that's better than segfaulting in other random parts of
the library.
Fixes the crash https://bugzilla.gnome.org/show_bug.cgi?id=767220 but we'll
need to dig deeper working out what is calling as_app_add_pkgname() with NULL.
-rw-r--r-- | libappstream-glib/as-app.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index 87a2236..0de4fc6 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -2179,6 +2179,8 @@ as_app_add_category (AsApp *app, const gchar *category) { AsAppPrivate *priv = GET_PRIVATE (app); + g_return_if_fail (category != NULL); + /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && !as_app_validate_utf8 (category)) { @@ -2214,6 +2216,8 @@ as_app_add_compulsory_for_desktop (AsApp *app, const gchar *compulsory_for_deskt { AsAppPrivate *priv = GET_PRIVATE (app); + g_return_if_fail (compulsory_for_desktop != NULL); + /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && !as_app_validate_utf8 (compulsory_for_desktop)) { @@ -2249,6 +2253,8 @@ as_app_add_keyword (AsApp *app, GPtrArray *tmp; g_autofree gchar *tmp_locale = NULL; + g_return_if_fail (keyword != NULL); + /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && !as_app_validate_utf8 (keyword)) { @@ -2286,6 +2292,8 @@ as_app_add_kudo (AsApp *app, const gchar *kudo) { AsAppPrivate *priv = GET_PRIVATE (app); + g_return_if_fail (kudo != NULL); + /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && !as_app_validate_utf8 (kudo)) { @@ -2312,6 +2320,8 @@ as_app_add_permission (AsApp *app, const gchar *permission) { AsAppPrivate *priv = GET_PRIVATE (app); + g_return_if_fail (permission != NULL); + /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && !as_app_validate_utf8 (permission)) { @@ -2353,6 +2363,8 @@ as_app_add_mimetype (AsApp *app, const gchar *mimetype) { AsAppPrivate *priv = GET_PRIVATE (app); + g_return_if_fail (mimetype != NULL); + /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && !as_app_validate_utf8 (mimetype)) { @@ -2696,6 +2708,8 @@ as_app_add_pkgname (AsApp *app, const gchar *pkgname) { AsAppPrivate *priv = GET_PRIVATE (app); + g_return_if_fail (pkgname != NULL); + /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && !as_app_validate_utf8 (pkgname)) { @@ -2724,6 +2738,8 @@ as_app_add_arch (AsApp *app, const gchar *arch) { AsAppPrivate *priv = GET_PRIVATE (app); + g_return_if_fail (arch != NULL); + /* handle untrusted */ if ((priv->trust_flags & AS_APP_TRUST_FLAG_CHECK_VALID_UTF8) > 0 && !as_app_validate_utf8 (arch)) { |