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 628b935..1edeb3e 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 010b9be..39090d6 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 a2d6797..5861810 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;
 }