]> wimlib.net Git - wimlib/blobdiff - src/security.c
extract_wim_resource() refactor
[wimlib] / src / security.c
index ec1590f6f09a7636ff9a29a929eaf0712ff71a1a..c084258e007961a52ee8e5794f39a01bf93dd9bd 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 #include "wimlib_internal.h"
-#include "io.h"
+#include "buffer_io.h"
 #include "security.h"
 
 /*
@@ -40,7 +40,7 @@
  * entries anyway; however this ensures that that the security descriptors pass
  * the validation in libntfs-3g.
  */
-static void empty_sacl_fixup(char *descr, u64 *size_p)
+static void empty_sacl_fixup(u8 *descr, u64 *size_p)
 {
        if (*size_p >= sizeof(SecurityDescriptor)) {
                SecurityDescriptor *sd = (SecurityDescriptor*)descr;
@@ -195,9 +195,9 @@ int read_security_data(const u8 metadata_resource[], u64 metadata_resource_len,
                empty_sacl_fixup(sd->descriptors[i], &sd->sizes[i]);
        }
        wimlib_assert(total_len <= 0xffffffff);
-       if ((total_len + 7 & ~7) != ((sd->total_length + 7) & ~7)) {
+       if (((total_len + 7) & ~7) != ((sd->total_length + 7) & ~7)) {
                ERROR("Expected security data total length = %u, but "
-                     "calculated %u", sd->total_length, total_len);
+                     "calculated %u", sd->total_length, (unsigned)total_len);
                goto out_invalid_sd;
        }
        sd->total_length = total_len;
@@ -250,7 +250,7 @@ static void print_acl(const u8 *p, const char *type)
        printf("    ACE Count = %u\n", ace_count);
 
        p += sizeof(ACL);
-       for (uint i = 0; i < acl->ace_count; i++) {
+       for (u16 i = 0; i < ace_count; i++) {
                const ACEHeader *hdr = (const ACEHeader*)p;
                printf("        [ACE]\n");
                printf("        ACE type  = %d\n", hdr->type);
@@ -274,7 +274,7 @@ static void print_sid(const u8 *p, const char *type)
        print_byte_field(sid->identifier_authority,
                         sizeof(sid->identifier_authority));
        putchar('\n');
-       for (uint i = 0; i < sid->sub_authority_count; i++)
+       for (u8 i = 0; i < sid->sub_authority_count; i++)
                printf("    Subauthority %u = %u\n",
                       i, le32_to_cpu(sid->sub_authority[i]));
        putchar('\n');
@@ -328,17 +328,17 @@ void print_security_data(const struct wim_security_data *sd)
 
 void free_security_data(struct wim_security_data *sd)
 {
-       if (!sd)
-               return;
-       wimlib_assert(sd->refcnt != 0);
-       if (--sd->refcnt == 0) {
-               u8 **descriptors = sd->descriptors;
-               u32 num_entries  = sd->num_entries;
-               if (descriptors)
-                       while (num_entries--)
-                               FREE(*descriptors++);
-               FREE(sd->sizes);
-               FREE(sd->descriptors);
-               FREE(sd);
+       if (sd) {
+               wimlib_assert(sd->refcnt != 0);
+               if (--sd->refcnt == 0) {
+                       u8 **descriptors = sd->descriptors;
+                       u32 num_entries  = sd->num_entries;
+                       if (descriptors)
+                               while (num_entries--)
+                                       FREE(*descriptors++);
+                       FREE(sd->sizes);
+                       FREE(sd->descriptors);
+                       FREE(sd);
+               }
        }
 }