Skip to content
This repository was archived by the owner on May 22, 2019. It is now read-only.

Commit 65196d0

Browse files
committed
Ensure that custom user .face images are added to allowed paths list. Fixes #98
1 parent 3690b89 commit 65196d0

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/webkit2-extension.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,24 +276,33 @@ get_user_image_cb(JSContextRef context,
276276
JSObjectRef thisObject,
277277
JSStringRef propertyName,
278278
JSValueRef *exception) {
279-
const gchar *image_uri = lightdm_user_get_image(USER);
279+
280+
const gchar *image = lightdm_user_get_image(USER);
280281
gchar *image_path;
281282
gint result;
282283

283-
image_path = g_filename_from_uri(image_uri, NULL, NULL);
284-
if (image_path) {
285-
result = g_access(image_path, R_OK);
286-
g_free(image_path);
287-
} else {
288-
result = g_access(image_uri, R_OK);
284+
// Determine if we already checked this path
285+
for (iter = paths; iter; iter = iter->next) {
286+
if (0 == g_strcmp0(image, iter->data)) {
287+
// We've already checked this path, no need to continue further.
288+
return string_or_null(context, image);
289+
}
289290
}
290291

291-
if (result) {
292-
/* Couldn't access */
293-
return JSValueMakeNull(context);
294-
} else {
295-
return string_or_null(context, image_uri);
292+
image_path = g_strdup(image);
293+
result = g_access(image_path, R_OK);
294+
295+
if (0 == result) {
296+
// Path is accessible. Add it to our paths list.
297+
paths = g_slist_prepend(paths, image_path);
298+
299+
return string_or_null(context, image);
296300
}
301+
302+
// Path is not accessible.
303+
g_free(image_path);
304+
305+
return JSValueMakeNull(context);
297306
}
298307

299308

@@ -1835,7 +1844,7 @@ should_block_request(const char *file_path) {
18351844

18361845
if (NULL != canonical_path) {
18371846
for (iter = paths; iter; iter = iter->next) {
1838-
if (strcmp(canonical_path, iter->data) == 0 || g_str_has_prefix(canonical_path, iter->data)) {
1847+
if (0 == g_strcmp0(canonical_path, iter->data) || g_str_has_prefix(canonical_path, iter->data)) {
18391848
result = FALSE; /* Allowed */
18401849
break;
18411850
}

0 commit comments

Comments
 (0)