]> wimlib.net Git - wimlib/commitdiff
New helper function: inode_has_security_descriptor()
authorEric Biggers <ebiggers3@gmail.com>
Sat, 30 May 2015 20:48:20 +0000 (15:48 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 5 Jun 2015 03:05:38 +0000 (22:05 -0500)
include/wimlib/inode.h
src/extract.c
src/iterate_dir.c
src/ntfs-3g_apply.c
src/win32_apply.c

index 08f414d0d7ca6857b90dbffa0396fabfd59784a0..3fbb4039d658af19289762946dd16cd127f7bf60 100644 (file)
@@ -157,10 +157,8 @@ struct wim_inode {
 
        /* Corresponds to 'security_id' in `struct wim_dentry_on_disk':  The
         * index of this inode's security descriptor in the WIM image's table of
 
        /* Corresponds to 'security_id' in `struct wim_dentry_on_disk':  The
         * index of this inode's security descriptor in the WIM image's table of
-        * security descriptors, or -1.  Note: when a WIM image is loaded,
-        * wimlib sets out-of-bounds indices and values less than -1 in this
-        * field to -1.  So the extraction code need not do an upper bound check
-        * after checking for -1 (or equivalently < 0).  */
+        * security descriptors, or -1 if this inode does not have a security
+        * descriptor.  */
        s32 i_security_id;
 
        /* Unknown field that we only read into memory so we can re-write it
        s32 i_security_id;
 
        /* Unknown field that we only read into memory so we can re-write it
@@ -324,6 +322,13 @@ inode_has_children(const struct wim_inode *inode)
        return inode->i_children != NULL;
 }
 
        return inode->i_children != NULL;
 }
 
+/* Does the inode have a security descriptor?  */
+static inline bool
+inode_has_security_descriptor(const struct wim_inode *inode)
+{
+       return inode->i_security_id >= 0;
+}
+
 extern struct wim_inode_stream *
 inode_get_stream(const struct wim_inode *inode, int stream_type,
                 const utf16lechar *stream_name);
 extern struct wim_inode_stream *
 inode_get_stream(const struct wim_inode *inode, int stream_type,
                 const utf16lechar *stream_name);
index 5fcf52480ee2ca9cd95712c0edb905da843ba642..cf8a2c922379b424a3986b6c6871259f7bb6d6b4 100644 (file)
@@ -1157,7 +1157,7 @@ inode_tally_features(const struct wim_inode *inode,
                else
                        features->other_reparse_points++;
        }
                else
                        features->other_reparse_points++;
        }
-       if (inode->i_security_id != -1)
+       if (inode_has_security_descriptor(inode))
                features->security_descriptors++;
        if (inode_has_unix_data(inode))
                features->unix_data++;
                features->security_descriptors++;
        if (inode_has_unix_data(inode))
                features->unix_data++;
index 5bf138cc49e33c1da83ec9fbf9c922b29d2e474f..451143a765f9015236345f40f01640e07d646a7a 100644 (file)
@@ -109,7 +109,7 @@ init_wimlib_dentry(struct wimlib_dir_entry *wdentry, struct wim_dentry *dentry,
        for (struct wim_dentry *d = dentry; !dentry_is_root(d); d = d->d_parent)
                wdentry->depth++;
 
        for (struct wim_dentry *d = dentry; !dentry_is_root(d); d = d->d_parent)
                wdentry->depth++;
 
-       if (inode->i_security_id >= 0) {
+       if (inode_has_security_descriptor(inode)) {
                struct wim_security_data *sd;
 
                sd = wim_get_current_security_data(wim);
                struct wim_security_data *sd;
 
                sd = wim_get_current_security_data(wim);
index f0386b1245a025c6138308f8e13cfb9676172684..10f514cd9481378b3b91de556893cbcafa31f5a0 100644 (file)
@@ -385,7 +385,7 @@ ntfs_3g_set_metadata(ntfs_inode *ni, const struct wim_inode *inode,
        }
 
        /* Security descriptor  */
        }
 
        /* Security descriptor  */
-       if ((inode->i_security_id >= 0)
+       if (inode_has_security_descriptor(inode)
            && !(extract_flags & WIMLIB_EXTRACT_FLAG_NO_ACLS))
        {
                const void *desc;
            && !(extract_flags & WIMLIB_EXTRACT_FLAG_NO_ACLS))
        {
                const void *desc;
index 7bacac9d50b42a742f92f39a6da386cf4fef7d1b..f4a2d753252181d1ba9ae5385a4aa93802868be8 100644 (file)
@@ -2451,7 +2451,7 @@ do_apply_metadata_to_file(HANDLE h, const struct wim_inode *inode,
        NTSTATUS status;
 
        /* Set security descriptor if present and not in NO_ACLS mode  */
        NTSTATUS status;
 
        /* Set security descriptor if present and not in NO_ACLS mode  */
-       if (inode->i_security_id >= 0 &&
+       if (inode_has_security_descriptor(inode) &&
            !(ctx->common.extract_flags & WIMLIB_EXTRACT_FLAG_NO_ACLS))
        {
                const struct wim_security_data *sd;
            !(ctx->common.extract_flags & WIMLIB_EXTRACT_FLAG_NO_ACLS))
        {
                const struct wim_security_data *sd;