From: Toni Wilen Date: Fri, 31 Jan 2020 17:56:52 +0000 (+0200) Subject: Check and reject too large physical block sizes. X-Git-Tag: 4400~158 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=7fcbed668d9db076bf5fa7a41d609823ab51f38b;p=francis%2Fwinuae.git Check and reject too large physical block sizes. --- diff --git a/filesys.cpp b/filesys.cpp index cb2a77b3..f488f401 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -8263,6 +8263,8 @@ static int pt_babe(TrapContext *ctx, uae_u8 *bufrdb, UnitInfo *uip, int unit_no, bad = rl(bufrdb + 4); if (bad) { + if (bad * hfd->ci.blocksize > FILESYS_MAX_BLOCKSIZE) + return 0; hdf_read_rdb(hfd, bufrdb2, bad * hfd->ci.blocksize, hfd->ci.blocksize); if (bufrdb2[0] != 0xBA || bufrdb2[1] != 0xD1) return 0; @@ -8559,6 +8561,11 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, return -2; } + if (hfd->ci.blocksize > FILESYS_MAX_BLOCKSIZE) { + write_log(_T("failed, too large block size %d\n"), hfd->ci.blocksize); + return -2; + } + for (rdblock = 0; rdblock < lastblock; rdblock++) { hdf_read_rdb (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); if (rdblock == 0 && bufrdb[0] == 0xBA && bufrdb[1] == 0xBE) { diff --git a/include/filesys.h b/include/filesys.h index 728c0f8b..c2bc0883 100644 --- a/include/filesys.h +++ b/include/filesys.h @@ -127,7 +127,7 @@ extern struct uaedev_mount_info options_mountinfo; extern struct hardfiledata *get_hardfile_data(int nr); extern struct hardfiledata *get_hardfile_data_controller(int nr); -#define FILESYS_MAX_BLOCKSIZE 2048 +#define FILESYS_MAX_BLOCKSIZE 8192 extern int hdf_open (struct hardfiledata *hfd); extern int hdf_open (struct hardfiledata *hfd, const TCHAR *altname); extern int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd);