From 04e696c3c812834ba07fb3673da4ee08e8106b0d Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 23 Mar 2018 10:48:44 -0400 Subject: [PATCH] jsauthority: JSVAL_IS_STRING (s) to s.isString() Signed-off-by: Ray Strode https://bugs.freedesktop.org/show_bug.cgi?id=105865 --- src/polkitbackend/polkitbackendjsauthority.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp index bc33a59..71394d7 100644 --- a/src/polkitbackend/polkitbackendjsauthority.cpp +++ b/src/polkitbackend/polkitbackendjsauthority.cpp @@ -1102,61 +1102,61 @@ polkit_backend_js_authority_get_admin_auth_identities (PolkitBackendInteractiveA g_clear_error (&error); goto out; } if (!subject_to_jsval (authority, subject, user_for_subject, subject_is_local, subject_is_active, &argv[1], &error)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error converting subject to JS object: %s", error->message); g_clear_error (&error); goto out; } if (!call_js_function_with_runaway_killer (authority, "_runAdminRules", G_N_ELEMENTS (argv), argv, &rval)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error evaluating admin rules"); goto out; } - if (!JSVAL_IS_STRING (rval)) + if (!rval.isString()) { g_warning ("Expected a string"); goto out; } ret_jsstr = rval.toString(); ret_str = g_utf16_to_utf8 (JS_GetStringCharsZ (authority->priv->cx, ret_jsstr), -1, NULL, NULL, NULL); if (ret_str == NULL) { g_warning ("Error converting resulting string to UTF-8: %s", error->message); goto out; } ret_strs = g_strsplit (ret_str, ",", -1); for (n = 0; ret_strs != NULL && ret_strs[n] != NULL; n++) { const gchar *identity_str = ret_strs[n]; PolkitIdentity *identity; error = NULL; identity = polkit_identity_from_string (identity_str, &error); if (identity == NULL) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Identity `%s' is not valid, ignoring", identity_str); } else { ret = g_list_prepend (ret, identity); @@ -1218,61 +1218,61 @@ polkit_backend_js_authority_check_authorization_sync (PolkitBackendInteractiveAu subject_is_local, subject_is_active, &argv[1], &error)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error converting subject to JS object: %s", error->message); g_clear_error (&error); goto out; } if (!call_js_function_with_runaway_killer (authority, "_runRules", G_N_ELEMENTS (argv), argv, &rval)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Error evaluating authorization rules"); goto out; } if (JSVAL_IS_NULL (rval)) { /* this fine, means there was no match, use implicit authorizations */ good = TRUE; goto out; } - if (!JSVAL_IS_STRING (rval)) + if (!rval.isString()) { g_warning ("Expected a string"); goto out; } ret_jsstr = rval.toString(); ret_utf16 = JS_GetStringCharsZ (authority->priv->cx, ret_jsstr); ret_str = g_utf16_to_utf8 (ret_utf16, -1, NULL, NULL, &error); if (ret_str == NULL) { g_warning ("Error converting resulting string to UTF-8: %s", error->message); g_clear_error (&error); goto out; } g_strstrip (ret_str); if (!polkit_implicit_authorization_from_string (ret_str, &ret)) { polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority), "Returned result `%s' is not valid", ret_str); goto out; } good = TRUE; out: if (!good) ret = POLKIT_IMPLICIT_AUTHORIZATION_NOT_AUTHORIZED; g_free (ret_str); @@ -1384,61 +1384,61 @@ js_polkit_spawn (JSContext *cx, gint exit_status; GError *error = NULL; JSString *ret_jsstr; guint32 array_len; gchar **argv = NULL; GMainContext *context = NULL; GMainLoop *loop = NULL; SpawnData data = {0}; guint n; if (!JS_ConvertArguments (cx, js_argc, JS_ARGV (cx, vp), "o", &array_object)) goto out; if (!JS_GetArrayLength (cx, array_object, &array_len)) { JS_ReportErrorUTF8 (cx, "Failed to get array length"); goto out; } argv = g_new0 (gchar*, array_len + 1); for (n = 0; n < array_len; n++) { JS::Value elem_val; char *s; if (!JS_GetElement (cx, array_object, n, &elem_val)) { JS_ReportErrorUTF8 (cx, "Failed to get element %d", n); goto out; } - if (!JSVAL_IS_STRING (elem_val)) + if (!elem_val.isString()) { JS_ReportErrorUTF8 (cx, "Element %d is not a string", n); goto out; } s = JS_EncodeString (cx, elem_val.toString()); argv[n] = g_strdup (s); JS_free (cx, s); } context = g_main_context_new (); loop = g_main_loop_new (context, FALSE); g_main_context_push_thread_default (context); data.loop = loop; utils_spawn ((const gchar *const *) argv, 10, /* timeout_seconds */ NULL, /* cancellable */ spawn_cb, &data); g_main_loop_run (loop); g_main_context_pop_thread_default (context); if (!utils_spawn_finish (data.res, &exit_status, &standard_output, &standard_error, &error)) -- 2.16.2