]> wimlib.net Git - wimlib/blobdiff - src/write.c
Add GUID helper functions
[wimlib] / src / write.c
index d0ede8bb9a42b6d87d964384254e04930f27c8c3..4d5e71651abceb3d411b3549d094705f28693827 100644 (file)
@@ -1747,6 +1747,13 @@ write_wim_resource_from_buffer(const void *buf,
        int ret;
        struct blob_descriptor blob;
 
+       if (unlikely(buf_size == 0)) {
+               zero_reshdr(out_reshdr);
+               if (hash_ret)
+                       copy_hash(hash_ret, zero_hash);
+               return 0;
+       }
+
        blob_set_is_located_in_attached_buffer(&blob, (void *)buf, buf_size);
        sha1_buffer(buf, buf_size, blob.hash);
        blob.unhashed = 0;
@@ -2744,9 +2751,9 @@ write_wim_part(WIMStruct *wim,
        if (write_flags & WIMLIB_WRITE_FLAG_RETAIN_GUID)
                guid = wim->hdr.guid;
        if (guid)
-               memcpy(wim->out_hdr.guid, guid, WIMLIB_GUID_LEN);
+               copy_guid(wim->out_hdr.guid, guid);
        else
-               randomize_byte_array(wim->out_hdr.guid, WIMLIB_GUID_LEN);
+               generate_guid(wim->out_hdr.guid);
 
        /* Set the part number and total parts.  */
        wim->out_hdr.part_number = part_number;