diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-06-28 21:25:17 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-07-06 17:05:50 +0200 |
commit | dce9e92834cc4f962e547cae46b73ca559d05b0c (patch) | |
tree | 1b5e1d2ed18ceccee9438c271f383b50b8374fff /hw | |
parent | 7aa9c811ca0761918a0252d0f923a80224953fa6 (diff) |
ide: Reject invalid CHS geometry
drive_init() doesn't permit invalid CHS for if=ide, but that's
worthless: we get it via if=none and -device.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ide/core.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c index 3b84bea5cf..af52c2cb2d 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2604,6 +2604,18 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, s->bs = bs; bdrv_get_geometry(bs, &nb_sectors); bdrv_guess_geometry(bs, &cylinders, &heads, &secs); + if (cylinders < 1 || cylinders > 16383) { + error_report("cyls must be between 1 and 16383"); + return -1; + } + if (heads < 1 || heads > 16) { + error_report("heads must be between 1 and 16"); + return -1; + } + if (secs < 1 || secs > 63) { + error_report("secs must be between 1 and 63"); + return -1; + } s->cylinders = cylinders; s->heads = heads; s->sectors = secs; |