From 0938c56fdc93b9a40edaf9823f4f2bc033098787 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Fri, 5 Jul 2013 22:26:47 +0100 Subject: [PATCH] [syslinux] fix crash when installing syslinux on large drives * The check for minfatsize seems erroneous, and libfat_open() errors weren't checked in syslinux.c anyway * Closes #156 --- src/rufus.rc | 10 +++++----- src/syslinux.c | 6 +++++- src/syslinux/libfat/open.c | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/rufus.rc b/src/rufus.rc index 78324a31..86c1d3aa 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -30,7 +30,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.3.4.265" +CAPTION "Rufus v1.3.4.266" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -278,8 +278,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,3,4,265 - PRODUCTVERSION 1,3,4,265 + FILEVERSION 1,3,4,266 + PRODUCTVERSION 1,3,4,266 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -296,13 +296,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.3.4.265" + VALUE "FileVersion", "1.3.4.266" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.3.4.265" + VALUE "ProductVersion", "1.3.4.266" END END BLOCK "VarFileInfo" diff --git a/src/syslinux.c b/src/syslinux.c index 0b621b75..7298f0c8 100644 --- a/src/syslinux.c +++ b/src/syslinux.c @@ -146,7 +146,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter) /* Reopen the volume (we already have a lock) */ d_handle = GetLogicalHandle(drive_index, TRUE, FALSE); if (d_handle == INVALID_HANDLE_VALUE) { - uprintf("Could open volume for syslinux operation\n"); + uprintf("Could open volume for Syslinux installation\n"); goto out; } @@ -156,6 +156,10 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter) if (sectors == NULL) goto out; fs = libfat_open(libfat_readfile, (intptr_t) d_handle); + if (fs == NULL) { + uprintf("FAT access error\n"); + goto out; + } ldlinux_cluster = libfat_searchdir(fs, 0, "LDLINUX SYS", NULL); secp = sectors; nsectors = 0; diff --git a/src/syslinux/libfat/open.c b/src/syslinux/libfat/open.c index 43c4b085..ebc94f17 100644 --- a/src/syslinux/libfat/open.c +++ b/src/syslinux/libfat/open.c @@ -92,10 +92,13 @@ libfat_open(int (*readfunc) (intptr_t, void *, size_t, libfat_sector_t), } else goto barf; /* Impossibly many clusters */ + /* This check doesn't hold for Large FAT32 => remove it */ +#if 0 minfatsize = (minfatsize + LIBFAT_SECTOR_SIZE - 1) >> LIBFAT_SECTOR_SHIFT; if (minfatsize > fatsize) goto barf; /* The FATs don't fit */ +#endif if (fs->fat_type == FAT28) fs->rootcluster = read32(&bs->u.fat32.bpb_rootclus);