projects
/
pub
/
USBasp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8802907
)
Fixed bootloaders accepting flash writes to the bootloader region (thanks to NicoHood).
author
Dean Camera
<dean@fourwalledcubicle.com>
Mon, 22 Jan 2018 05:14:44 +0000
(16:14 +1100)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Mon, 22 Jan 2018 05:14:44 +0000
(16:14 +1100)
Bootloaders/CDC/BootloaderAPI.c
patch
|
blob
|
blame
|
history
Bootloaders/DFU/BootloaderAPI.c
patch
|
blob
|
blame
|
history
Bootloaders/HID/BootloaderHID.c
patch
|
blob
|
blame
|
history
Bootloaders/MassStorage/BootloaderAPI.c
patch
|
blob
|
blame
|
history
Bootloaders/Printer/BootloaderAPI.c
patch
|
blob
|
blame
|
history
LUFA/DoxygenPages/ChangeLog.txt
patch
|
blob
|
blame
|
history
diff --git
a/Bootloaders/CDC/BootloaderAPI.c
b/Bootloaders/CDC/BootloaderAPI.c
index
5e8083e
..
c1e76d3
100644
(file)
--- a/
Bootloaders/CDC/BootloaderAPI.c
+++ b/
Bootloaders/CDC/BootloaderAPI.c
@@
-35,8
+35,20
@@
#include "BootloaderAPI.h"
#include "BootloaderAPI.h"
+static bool IsPageAddressValid(const uint32_t Address)
+{
+ /* Determine if the given page address is correctly aligned to the
+ start of a flash page. */
+ bool PageAddressIsAligned = !(Address & (SPM_PAGESIZE - 1));
+
+ return (Address < BOOT_START_ADDR) && PageAddressIsAligned;
+}
+
void BootloaderAPI_ErasePage(const uint32_t Address)
{
void BootloaderAPI_ErasePage(const uint32_t Address)
{
+ if (! IsPageAddressValid(Address))
+ return;
+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_erase_safe(Address);
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_erase_safe(Address);
@@
-47,6
+59,9
@@
void BootloaderAPI_ErasePage(const uint32_t Address)
void BootloaderAPI_WritePage(const uint32_t Address)
{
void BootloaderAPI_WritePage(const uint32_t Address)
{
+ if (! IsPageAddressValid(Address))
+ return;
+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_write_safe(Address);
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_write_safe(Address);
diff --git
a/Bootloaders/DFU/BootloaderAPI.c
b/Bootloaders/DFU/BootloaderAPI.c
index
5e8083e
..
c1e76d3
100644
(file)
--- a/
Bootloaders/DFU/BootloaderAPI.c
+++ b/
Bootloaders/DFU/BootloaderAPI.c
@@
-35,8
+35,20
@@
#include "BootloaderAPI.h"
#include "BootloaderAPI.h"
+static bool IsPageAddressValid(const uint32_t Address)
+{
+ /* Determine if the given page address is correctly aligned to the
+ start of a flash page. */
+ bool PageAddressIsAligned = !(Address & (SPM_PAGESIZE - 1));
+
+ return (Address < BOOT_START_ADDR) && PageAddressIsAligned;
+}
+
void BootloaderAPI_ErasePage(const uint32_t Address)
{
void BootloaderAPI_ErasePage(const uint32_t Address)
{
+ if (! IsPageAddressValid(Address))
+ return;
+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_erase_safe(Address);
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_erase_safe(Address);
@@
-47,6
+59,9
@@
void BootloaderAPI_ErasePage(const uint32_t Address)
void BootloaderAPI_WritePage(const uint32_t Address)
{
void BootloaderAPI_WritePage(const uint32_t Address)
{
+ if (! IsPageAddressValid(Address))
+ return;
+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_write_safe(Address);
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_write_safe(Address);
diff --git
a/Bootloaders/HID/BootloaderHID.c
b/Bootloaders/HID/BootloaderHID.c
index
c21bf56
..
e5b7d32
100644
(file)
--- a/
Bootloaders/HID/BootloaderHID.c
+++ b/
Bootloaders/HID/BootloaderHID.c
@@
-152,6
+152,10
@@
void EVENT_USB_Device_ControlRequest(void)
uint16_t PageAddress = Endpoint_Read_16_LE();
#endif
uint16_t PageAddress = Endpoint_Read_16_LE();
#endif
+ /* Determine if the given page address is correctly aligned to the
+ start of a flash page. */
+ bool PageAddressIsAligned = !(PageAddress & (SPM_PAGESIZE - 1));
+
/* Check if the command is a program page command, or a start application command */
#if (FLASHEND > 0xFFFF)
if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION)
/* Check if the command is a program page command, or a start application command */
#if (FLASHEND > 0xFFFF)
if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION)
@@
-161,7
+165,7
@@
void EVENT_USB_Device_ControlRequest(void)
{
RunBootloader = false;
}
{
RunBootloader = false;
}
- else if (
PageAddress < BOOT_START_ADDR
)
+ else if (
(PageAddress < BOOT_START_ADDR) && PageAddressIsAligned
)
{
/* Erase the given FLASH page, ready to be programmed */
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
/* Erase the given FLASH page, ready to be programmed */
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
diff --git
a/Bootloaders/MassStorage/BootloaderAPI.c
b/Bootloaders/MassStorage/BootloaderAPI.c
index
5e8083e
..
c1e76d3
100644
(file)
--- a/
Bootloaders/MassStorage/BootloaderAPI.c
+++ b/
Bootloaders/MassStorage/BootloaderAPI.c
@@
-35,8
+35,20
@@
#include "BootloaderAPI.h"
#include "BootloaderAPI.h"
+static bool IsPageAddressValid(const uint32_t Address)
+{
+ /* Determine if the given page address is correctly aligned to the
+ start of a flash page. */
+ bool PageAddressIsAligned = !(Address & (SPM_PAGESIZE - 1));
+
+ return (Address < BOOT_START_ADDR) && PageAddressIsAligned;
+}
+
void BootloaderAPI_ErasePage(const uint32_t Address)
{
void BootloaderAPI_ErasePage(const uint32_t Address)
{
+ if (! IsPageAddressValid(Address))
+ return;
+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_erase_safe(Address);
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_erase_safe(Address);
@@
-47,6
+59,9
@@
void BootloaderAPI_ErasePage(const uint32_t Address)
void BootloaderAPI_WritePage(const uint32_t Address)
{
void BootloaderAPI_WritePage(const uint32_t Address)
{
+ if (! IsPageAddressValid(Address))
+ return;
+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_write_safe(Address);
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_write_safe(Address);
diff --git
a/Bootloaders/Printer/BootloaderAPI.c
b/Bootloaders/Printer/BootloaderAPI.c
index
5e8083e
..
c1e76d3
100644
(file)
--- a/
Bootloaders/Printer/BootloaderAPI.c
+++ b/
Bootloaders/Printer/BootloaderAPI.c
@@
-35,8
+35,20
@@
#include "BootloaderAPI.h"
#include "BootloaderAPI.h"
+static bool IsPageAddressValid(const uint32_t Address)
+{
+ /* Determine if the given page address is correctly aligned to the
+ start of a flash page. */
+ bool PageAddressIsAligned = !(Address & (SPM_PAGESIZE - 1));
+
+ return (Address < BOOT_START_ADDR) && PageAddressIsAligned;
+}
+
void BootloaderAPI_ErasePage(const uint32_t Address)
{
void BootloaderAPI_ErasePage(const uint32_t Address)
{
+ if (! IsPageAddressValid(Address))
+ return;
+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_erase_safe(Address);
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_erase_safe(Address);
@@
-47,6
+59,9
@@
void BootloaderAPI_ErasePage(const uint32_t Address)
void BootloaderAPI_WritePage(const uint32_t Address)
{
void BootloaderAPI_WritePage(const uint32_t Address)
{
+ if (! IsPageAddressValid(Address))
+ return;
+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_write_safe(Address);
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
boot_page_write_safe(Address);
diff --git
a/LUFA/DoxygenPages/ChangeLog.txt
b/LUFA/DoxygenPages/ChangeLog.txt
index
8f299f7
..
147cacc
100644
(file)
--- a/
LUFA/DoxygenPages/ChangeLog.txt
+++ b/
LUFA/DoxygenPages/ChangeLog.txt
@@
-14,6
+14,7
@@
* character after a successful write (thanks to NicoHood)
* - Library Applications:
* - Fixed bootloaders not disabling global interrupts during erase and write operations (thanks to Zoltan)
* character after a successful write (thanks to NicoHood)
* - Library Applications:
* - Fixed bootloaders not disabling global interrupts during erase and write operations (thanks to Zoltan)
+ * - Fixed bootloaders accepting flash writes to the bootloader region (thanks to NicoHood)
*
* \section Sec_ChangeLog170418 Version 170418
* <b>New:</b>
*
* \section Sec_ChangeLog170418 Version 170418
* <b>New:</b>