Commit 20267bc0 authored by Richard Hughes's avatar Richard Hughes

Ensure EDID strings are printable, and ignore totally junk strings

parent be198a0c
......@@ -336,6 +336,8 @@ static gchar *
gcm_edid_parse_string (const guint8 *data)
{
gchar *text;
guint i;
guint replaced = 0;
/* copy 12 bytes */
text = g_strndup ((const gchar *) data, 12);
......@@ -350,7 +352,24 @@ gcm_edid_parse_string (const guint8 *data)
if (text[0] == '\0') {
g_free (text);
text = NULL;
goto out;
}
/* ensure string is printable */
for (i=0;i<12;i++) {
if (!g_ascii_isprint (text[i])) {
text[i] = '-';
replaced++;
}
}
/* if the string is junk, ignore the string */
if (replaced > 4) {
g_free (text);
text = NULL;
goto out;
}
out:
return text;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment