[gnome-color-manager] Ensure EDID strings are printable, and ignore totally junk strings
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Ensure EDID strings are printable, and ignore totally junk strings
- Date: Thu, 30 Sep 2010 17:00:20 +0000 (UTC)
commit 20267bc0f0c2838fe9108a6537acca22f01d7f4a
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 30 18:57:44 2010 +0100
Ensure EDID strings are printable, and ignore totally junk strings
libcolor-glib/gcm-edid.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/libcolor-glib/gcm-edid.c b/libcolor-glib/gcm-edid.c
index 819d51a..654fb75 100644
--- a/libcolor-glib/gcm-edid.c
+++ b/libcolor-glib/gcm-edid.c
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]