[gnome-color-manager/gnome-2-32] 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/gnome-2-32] Ensure EDID strings are printable, and ignore totally junk strings
- Date: Thu, 30 Sep 2010 17:02:17 +0000 (UTC)
commit f6274f9c42b26e081d5e3132f7674c593b85ed6b
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
src/gcm-edid.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/gcm-edid.c b/src/gcm-edid.c
index 75a68ac..6ca986d 100644
--- a/src/gcm-edid.c
+++ b/src/gcm-edid.c
@@ -253,6 +253,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);
@@ -267,7 +269,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]