Skip to content

Commit 0358490

Browse files
authored
Merge pull request #634 from visitorckw/fix-virtio-blk-overflow
Fix heap buffer overflow with -x option
2 parents 68fa45a + e11b229 commit 0358490

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ static bool parse_args(int argc, char **args)
131131
emu_argc++;
132132
break;
133133
case 'x':
134+
if (opt_virtio_blk_idx >= VBLK_DEV_MAX) {
135+
rv_log_error("Too many virtio-blk devices. Maximum is %d.\n",
136+
VBLK_DEV_MAX);
137+
return false;
138+
}
134139
if (!strncmp("vblk:", optarg, 5))
135140
opt_virtio_blk_img[opt_virtio_blk_idx++] =
136141
optarg + 5; /* strlen("vblk:") */

0 commit comments

Comments
 (0)