From: José Bollo <jose.bollo@iot.bzh>
Date: Wed, 14 Dec 2016 10:17:47 +0000 (+0100)
Subject: wgt-info: Enforce lower case ids and version
X-Git-Tag: chinook_3.0.0~4
X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=69df60bd6622a56200d2d03e1b7d899569adf650;p=src%2Fapp-framework-main.git

wgt-info: Enforce lower case ids and version

This will be used next to avoid faking identity
of applications using the case difference.

Change-Id: I13cbdd5124b58b2a72c15054df6f3cd0e11a2cc5
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
---

diff --git a/src/wgt-info.c b/src/wgt-info.c
index c8308fa..089a563 100644
--- a/src/wgt-info.c
+++ b/src/wgt-info.c
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <errno.h>
 #include <assert.h>
+#include <ctype.h>
 
 #include <libxml/tree.h>
 
@@ -117,6 +118,16 @@ static char *mkidaver(char *id, char *ver)
 	return NULL;
 }
 
+static void make_lowercase(char *s)
+{
+	if (s) {
+		while(*s) {
+			*s = (char)tolower(*s);
+			s++;
+		}
+	}
+}
+
 static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, int want_preferences)
 {
 	xmlNodePtr node, pnode;
@@ -132,8 +143,10 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i
 		return -1;
 	}
 	desc->id = xmlGetProp(node, wgt_config_string_id);
+	make_lowercase(desc->id);
 	desc->version = xmlGetProp(node, wgt_config_string_version);
 	desc->ver = mkver(desc->version);
+	make_lowercase(desc->ver);
 	desc->idaver = mkidaver(desc->id, desc->ver);
 	desc->width = getpropnum(node, wgt_config_string_width, 0);
 	desc->height = getpropnum(node, wgt_config_string_height, 0);