MSM: fix access type length and validation
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Fri, 10 Jan 2014 07:47:25 +0000 (09:47 +0200)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Fri, 10 Jan 2014 08:23:56 +0000 (10:23 +0200)
This patch fixes three issues with access type:

- SMACK_ACCESS_TYPE_LENGHT -> SMACK_ACCESS_TYPE_LENGTH
- Changed the value of SMACK_ACCESS_TYPE_LENGTH from 5 to 6.
- String length was calculated with unsafe 'strlen()'. Changed to
  use strlen(type, SMACK_LABEL_LENGTH + 1) instead.

Change-Id: I127d7b2beb8a3258ec1e4a5142f253f842b2fa7a
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
plugins/msm.h
plugins/msmmanifest.c

index f1bdcc819d6ebb04aa72c1d383e3ce55188b4bf5..30f85a7b1e5f8b2cf88b4151035d2f0d9d82c5a8 100644 (file)
@@ -39,7 +39,7 @@
 #define SMACK_ISOLATED_LABEL "Isolated"
 
 #define SMACK_LABEL_LENGTH 255
-#define SMACK_ACCESS_TYPE_LENGHT 5
+#define SMACK_ACCESS_TYPE_LENGTH 6
 #define SMACK_UNINSTALL 1 
 #define RANK_LIMIT 10000
 
index 5c14e097ce77868b12b5ad544f9bb6cb31f94a65..73f7c4b40872a78240da1cfcd66ec95ba9d6b163 100644 (file)
@@ -51,7 +51,8 @@ static int msmVerifyAccessType(const char* type)
     int res = 0, idx = 0;
 
     if (type) {
-        if (strlen(type) > SMACK_ACCESS_TYPE_LENGHT) {
+        if (strnlen(type, SMACK_ACCESS_TYPE_LENGTH + 1) >
+            SMACK_ACCESS_TYPE_LENGTH) {
             rpmlog(RPMLOG_ERR, "Lenght of the access type is bigger than allowed value: %s\n", type);
             return -1;
         }