[grilo-plugins] lua-factory: Ensure that fetches error out on non-UTF-8
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] lua-factory: Ensure that fetches error out on non-UTF-8
- Date: Wed, 7 May 2014 16:18:25 +0000 (UTC)
commit 2640e36928e905f56be0872e498b420427b38775
Author: Bastien Nocera <hadess hadess net>
Date: Fri Apr 18 17:08:43 2014 +0200
lua-factory: Ensure that fetches error out on non-UTF-8
This makes sure that we do not pass binary data as a result
for lua fetch operations.
https://bugzilla.gnome.org/show_bug.cgi?id=728525
src/lua-factory/grl-lua-library.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c
index 943ccc4..cbd795e 100644
--- a/src/lua-factory/grl-lua-library.c
+++ b/src/lua-factory/grl-lua-library.c
@@ -301,6 +301,7 @@ grl_util_fetch_done (GObject *source_object,
gpointer user_data)
{
gchar *data = NULL;
+ gsize len;
guint i = 0;
GError *err = NULL;
OperationSpec *os;
@@ -308,7 +309,12 @@ grl_util_fetch_done (GObject *source_object,
lua_State *L = fo->L;
grl_net_wc_request_finish (GRL_NET_WC (source_object),
- res, &data, NULL, &err);
+ res, &data, &len, &err);
+ if (!g_utf8_validate(data, len, NULL)) {
+ data = NULL;
+ g_set_error_literal (&err, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
+ "Fetched item is not valid UTF-8");
+ }
fo->results[fo->index] = (err == NULL) ? g_strdup (data) : g_strdup ("");
if (err != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]