Fix memcpy()s with overlapping buffers
authorEric Biggers <ebiggers3@gmail.com>
Tue, 1 Jan 2013 06:12:07 +0000 (00:12 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 1 Jan 2013 06:12:07 +0000 (00:12 -0600)
src/dentry.c
src/xml.c

index 08c08ab..03d56fc 100644 (file)
@@ -1117,9 +1117,9 @@ void inode_remove_ads(struct wim_inode *inode, u16 idx,
 
        destroy_ads_entry(ads_entry);
 
-       memcpy(&inode->i_ads_entries[idx],
-              &inode->i_ads_entries[idx + 1],
-              (inode->i_num_ads - idx - 1) * sizeof(inode->i_ads_entries[0]));
+       memmove(&inode->i_ads_entries[idx],
+               &inode->i_ads_entries[idx + 1],
+               (inode->i_num_ads - idx - 1) * sizeof(inode->i_ads_entries[0]));
        inode->i_num_ads--;
 }
 #endif
index ca2ec3e..9b161c2 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -952,9 +952,9 @@ void xml_delete_image(struct wim_info **wim_info_p, int image)
 
        destroy_image_info(&wim_info->images[image - 1]);
 
-       memcpy(&wim_info->images[image - 1],
-              &wim_info->images[image],
-              (wim_info->num_images - image) * sizeof(struct image_info));
+       memmove(&wim_info->images[image - 1],
+               &wim_info->images[image],
+               (wim_info->num_images - image) * sizeof(struct image_info));
 
        if (--wim_info->num_images == 0) {
                free_wim_info(wim_info);