When a VDI was restored from backup data, the buffer which was loaded backup data into was not allocated appropriately.
This patch fixes to allocate the buffer adequately Signed-off-by: Teruaki Ishizaki <[email protected]> --- dog/vdi.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/dog/vdi.c b/dog/vdi.c index 67e2f0b..4fee789 100644 --- a/dog/vdi.c +++ b/dog/vdi.c @@ -2536,6 +2536,7 @@ static uint32_t do_restore(const char *vdiname, int snapid, const char *tag) { int ret; uint32_t vid; + uint32_t object_size; struct backup_hdr hdr; struct obj_backup *backup = xzalloc(sizeof(*backup)); struct sd_inode *inode = xzalloc(sizeof(*inode)); @@ -2563,6 +2564,9 @@ static uint32_t do_restore(const char *vdiname, int snapid, const char *tag) goto out; } + object_size = (UINT32_C(1) << inode->block_size_shift); + backup->data = xzalloc(sizeof(uint8_t) * object_size); + while (true) { ret = xread(STDIN_FILENO, backup, sizeof(*backup) - sizeof(backup->data)); @@ -2592,6 +2596,7 @@ static uint32_t do_restore(const char *vdiname, int snapid, const char *tag) break; } } + free(backup->data); out: free(backup); free(inode); -- 1.7.1 -- sheepdog mailing list [email protected] https://lists.wpkg.org/mailman/listinfo/sheepdog
