From: Eric Biggers Date: Sat, 18 May 2013 04:29:16 +0000 (-0500) Subject: Add more uses of memdup, mempcpy X-Git-Tag: v1.4.0~8 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=97d8a488d7306e86a38a65f47441e5a5eb0712c5;ds=sidebyside Add more uses of memdup, mempcpy --- diff --git a/src/security.c b/src/security.c index 628b9358..1edeb3e3 100644 --- a/src/security.c +++ b/src/security.c @@ -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); diff --git a/src/win32_apply.c b/src/win32_apply.c index 010b9bee..39090d69 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -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. */ diff --git a/src/win32_capture.c b/src/win32_capture.c index a2d67976..58618102 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -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; }