diff options
-rw-r--r-- | MAINTAINERS | 2 | ||||
-rw-r--r-- | block/sheepdog.c | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 87ddaced59..afbe845bd7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1016,7 +1016,7 @@ F: blockjob.c F: include/block/blockjob.h F: block/backup.c F: block/commit.c -F: block/stream.h +F: block/stream.c F: block/mirror.c T: git git://github.com/codyprime/qemu-kvm-jtc.git block diff --git a/block/sheepdog.c b/block/sheepdog.c index a6e98a5a72..06ae3bac62 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2549,7 +2549,7 @@ static int sd_snapshot_delete(BlockDriverState *bs, const char *name, Error **errp) { - uint32_t snap_id = 0; + unsigned long snap_id = 0; char snap_tag[SD_MAX_VDI_TAG_LEN]; Error *local_err = NULL; int fd, ret; @@ -2571,12 +2571,15 @@ static int sd_snapshot_delete(BlockDriverState *bs, memset(buf, 0, sizeof(buf)); memset(snap_tag, 0, sizeof(snap_tag)); pstrcpy(buf, SD_MAX_VDI_LEN, s->name); - if (qemu_strtoul(snapshot_id, NULL, 10, (unsigned long *)&snap_id)) { - return -1; + ret = qemu_strtoul(snapshot_id, NULL, 10, &snap_id); + if (ret || snap_id > UINT32_MAX) { + error_setg(errp, "Invalid snapshot ID: %s", + snapshot_id ? snapshot_id : "<null>"); + return -EINVAL; } if (snap_id) { - hdr.snapid = snap_id; + hdr.snapid = (uint32_t) snap_id; } else { pstrcpy(snap_tag, sizeof(snap_tag), snapshot_id); pstrcpy(buf + SD_MAX_VDI_LEN, SD_MAX_VDI_TAG_LEN, snap_tag); |