Merge remote-tracking branch 'jsakkine/issue83' into v1.0.x
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Thu, 23 Jan 2014 12:54:39 +0000 (14:54 +0200)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Thu, 23 Jan 2014 12:54:39 +0000 (14:54 +0200)
Conflicts:
libsmack/libsmack.c

1  2 
libsmack/libsmack.c

@@@ -288,10 -287,29 +290,21 @@@ int smack_have_access(const char *subje
        if (smackfs_mnt_dirfd < 0)
                return -1;
  
 -      fd = openat(smackfs_mnt_dirfd, "access2", O_RDWR);
 -      if (fd < 0) {
 -              if (errno != ENOENT)
 -                      return -1;
 -
 -              fd = openat(smackfs_mnt_dirfd, "access", O_RDWR);
 -              if (fd < 0)
 -                      return -1;
 -
 -              use_long = 0;
 -      }
+       slen = get_label(NULL, subject);
+       olen = get_label(NULL, object);
+       if (slen < 0 || olen < 0)
+               return -1;
 +      fd = open_smackfs_file("access2", "access", &use_long);
 +      if (fd < 0)
 +              return -1;
  
+       if (!use_long && (slen > SHORT_LABEL_LEN || olen > SHORT_LABEL_LEN))  {
+               close(fd);
+               return -1;
+       }
        if ((code = str_to_access_code(access_type)) < 0)
                return -1;
        access_code_to_str(code, str);