From a10a207790a27b372d01f580d93f0fa937128c33 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 8 Mar 2016 17:28:45 +0000 Subject: [PATCH] [syslinux] fallback to embedded on version match if download fails * Could be useful for current tails user (6.03 based, same as ours) who want to create an UFD without downloading files. * Also improve the buffer overflow check in syslinux/libinstaller/syslxmod.c --- src/rufus.c | 9 +++++++-- src/rufus.rc | 10 +++++----- src/syslinux/libinstaller/syslxmod.c | 10 +++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/rufus.c b/src/rufus.c index ef5c507f..3e33c2b8 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -1468,8 +1468,13 @@ static BOOL BootCheck(void) } } if (syslinux_ldlinux_len[i] == 0) { - uprintf("Could not download the file - cancelling\n"); - return FALSE; + // If the version matches our embedded one, try to use that as a last ditch effort + if (img_report.sl_version == embedded_sl_version[1]) { + uprintf("Could not download the file - will try to use embedded %s version instead", img_report.sl_version_str); + } else { + uprintf("Could not download the file - cancelling\n"); + return FALSE; + } } } } diff --git a/src/rufus.rc b/src/rufus.rc index 1871c692..16f49f29 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.8.880" +CAPTION "Rufus 2.8.881" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -320,8 +320,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,8,880,0 - PRODUCTVERSION 2,8,880,0 + FILEVERSION 2,8,881,0 + PRODUCTVERSION 2,8,881,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -338,13 +338,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.8.880" + VALUE "FileVersion", "2.8.881" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.8.880" + VALUE "ProductVersion", "2.8.881" END END BLOCK "VarFileInfo" diff --git a/src/syslinux/libinstaller/syslxmod.c b/src/syslinux/libinstaller/syslxmod.c index 581f9fce..80d0b430 100644 --- a/src/syslinux/libinstaller/syslxmod.c +++ b/src/syslinux/libinstaller/syslxmod.c @@ -122,11 +122,11 @@ int syslinux_patch(const sector_t *sectp, int nsectors, return -1; /* The actual file is too small for content */ /* Search for LDLINUX_MAGIC to find the patch area */ - for (wp = (const uint32_t _slimg *)boot_image; - (get_32_sl(wp) != LDLINUX_MAGIC) && (((uintptr_t)wp) < ((uintptr_t)boot_image + boot_image_len)); - wp++) - ; - if (((uintptr_t)wp) >= ((uintptr_t)boot_image + boot_image_len)) + dw = (boot_image_len - sizeof(struct patch_area)) >> 2; + for (i = 0, wp = (const uint32_t _slimg *)boot_image; + (i <= dw) && ((get_32_sl(wp) != LDLINUX_MAGIC)); + i++, wp++) + if (i > dw) /* Not found */ return -1; patcharea = (struct patch_area _slimg *)wp; epa = slptr(boot_image, &patcharea->epaoffset);