From 15f5e297d06c64582bfb791f5fc82093b145816d Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Sun, 5 May 2019 06:38:47 +0000 Subject: [PATCH] loader: validate sectorsize argument in disk_open() The bug and patch is reported against 11.2, but it is good idea to have the check in place for all versions. PR: 236585 Submitted by: john@feith.com Reported by: john@feith.com MFC after: 1 day --- stand/common/disk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stand/common/disk.c b/stand/common/disk.c index fdcbcd3387fa..e1ce30b65378 100644 --- a/stand/common/disk.c +++ b/stand/common/disk.c @@ -221,6 +221,10 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize, u_int sectorsize) struct ptable_entry part; int rc, slice, partition; + if (sectorsize == 0) { + DPRINTF("unknown sector size"); + return (ENXIO); + } rc = 0; od = (struct open_disk *)malloc(sizeof(struct open_disk)); if (od == NULL) {