OSDN Git Service

ext4_utils: fix build error without FILE_CONTEXTS
authorSungmin Choi <sungmin.choi@lge.com>
Mon, 25 Feb 2013 06:37:51 +0000 (15:37 +0900)
committerSungmin Choi <sungmin.choi@lge.com>
Mon, 25 Feb 2013 06:39:45 +0000 (15:39 +0900)
After commit 4df62f342dbbe2f5cca831ce789dc0426d32ec03,
occurs segmentation fault if mkuserimg.sh runs without FILE_CONTEXTS options.
It's due to strlen() for null value. To fix it, return 0 for null.

Change-Id: Icf99706e51b9053a24e23b9d081a258962877c30

ext4_utils/contents.c

index 4899648..586e97e 100644 (file)
@@ -467,6 +467,9 @@ static int xattr_add(u32 inode_num, int name_index, const char *name,
 
 int inode_set_selinux(u32 inode_num, const char *secon)
 {
+       if (!secon)
+               return 0;
+
        return xattr_add(inode_num, EXT4_XATTR_INDEX_SECURITY,
                XATTR_SELINUX_SUFFIX, secon, strlen(secon) + 1);
 }