From ff0ec609312d150cc8c790277c678cad76b38f30 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Wed, 28 Sep 2016 03:03:42 +0200
Subject: Validate encoding in .ifo files
---
src/stardict.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/stardict.c b/src/stardict.c
index b7e7be4..1010ee1 100644
--- a/src/stardict.c
+++ b/src/stardict.c
@@ -253,6 +253,13 @@ load_ifo (StardictInfo *sti, const gchar *path, GError **error)
continue;
}
+ if (!g_utf8_validate (ir.value, -1, NULL))
+ {
+ g_set_error (error, STARDICT_ERROR, STARDICT_ERROR_INVALID_DATA,
+ "%s: %s", path, _("invalid encoding, must be valid UTF-8"));
+ goto error;
+ }
+
if (_stardict_ifo_keys[i].type == IFO_STRING)
{
G_STRUCT_MEMBER (gchar *, sti, _stardict_ifo_keys[i].offset)
--
cgit v1.2.3-70-g09d2