]> wimlib.net Git - wimlib/commitdiff
Add more uses of memdup, mempcpy
authorEric Biggers <ebiggers3@gmail.com>
Sat, 18 May 2013 04:29:16 +0000 (23:29 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 18 May 2013 04:29:16 +0000 (23:29 -0500)
src/security.c
src/win32_apply.c
src/win32_capture.c

index 628b93584d1dfff77727ecc9f845c85c2b6a6152..1edeb3e38dde1cd16f8b6b0985bb82467d5d58c8 100644 (file)
@@ -568,13 +568,12 @@ sd_set_add_sd(struct wim_sd_set *sd_set, const char *descriptor, size_t size)
        new = MALLOC(sizeof(*new));
        if (!new)
                goto out;
-       descr_copy = MALLOC(size);
+
+       descr_copy = memdup(descriptor, size);
        if (!descr_copy)
                goto out_free_node;
 
        sd = sd_set->sd;
-
-       memcpy(descr_copy, descriptor, size);
        new->security_id = sd->num_entries;
        copy_hash(new->hash, hash);
 
index 010b9bee6171fdbd3027b2b9907ff22304a5cfaf..39090d6910e0820501ade2ade8f89daf68f2cfd0 100644 (file)
@@ -106,8 +106,7 @@ win32_extract_try_rpfix(u8 *rpbuf,
        p = new_target;
        if (stripped_nchars == 6) {
                /* Include \??\ prefix if it was present before */
-               wmemcpy(p, L"\\??\\", 4);
-               p += 4;
+               p = wmempcpy(p, L"\\??\\", 4);
        }
 
        /* Print name excludes the \??\ if present. */
index a2d67976bc4ab5e3fcf6f979345dd880d654afd5..586181020d00a3153f059a1a145e8282700999eb 100644 (file)
@@ -154,9 +154,10 @@ win32_encrypted_export_cb(unsigned char *_data, void *_ctx, unsigned long len)
                }
        } else {
                size_t len_to_copy = min(len, ctx->bytes_remaining);
-               memcpy(ctx->read_prefix_ctx_or_buf, data, len_to_copy);
+               ctx->read_prefix_ctx_or_buf = mempcpy(ctx->read_prefix_ctx_or_buf,
+                                                     data,
+                                                     len_to_copy);
                ctx->bytes_remaining -= len_to_copy;
-               ctx->read_prefix_ctx_or_buf += len_to_copy;
        }
        return ERROR_SUCCESS;
 }