Fix for address calculation and access to object on memory.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2022-04-22 10:36:13 +09:00
parent cce65c6d34
commit 286b620648
5 changed files with 24 additions and 9 deletions

View File

@@ -1,3 +1,18 @@
2022-04-22 NIIBE Yutaka <gniibe@fsij.org>
* src/gnuk.h (_regnual_start): Fix type.
* src/main.c (main): Fix address for _regnual_start.
* src/usb_ctrl.c (mem_info, usb_setup): Follow the change.
* src/flash.c (_keystore_pool, _data_pool): Fix type.
(FLASH_ADDR_KEY_STORAGE_START, FLASH_ADDR_DATA_STORAGE_START):
Follow the change.
2022-03-26 Bertrand Jacquin <bertrand@jacquin.bzh>
* regnual/regnual.c (memset): Remove declaration.
* regnual/types.h (NULL): Remove.
(size_t): Remove.
2021-10-12 NIIBE Yutaka <gniibe@fsij.org>
* VERSION: 1.2.19.

View File

@@ -82,10 +82,10 @@ extern uint8_t *flash_addr_data_storage_start;
#define FLASH_ADDR_DATA_STORAGE_START flash_addr_data_storage_start
#else
/* Linker sets these symbols */
extern uint8_t _keystore_pool;
extern uint8_t _data_pool;
#define FLASH_ADDR_KEY_STORAGE_START ((&_keystore_pool))
#define FLASH_ADDR_DATA_STORAGE_START ((&_data_pool))
extern uint8_t _keystore_pool[];
extern uint8_t _data_pool[];
#define FLASH_ADDR_KEY_STORAGE_START ((_keystore_pool))
#define FLASH_ADDR_DATA_STORAGE_START ((_data_pool))
#endif
static int key_available_at (const uint8_t *k, int key_size)

View File

@@ -475,6 +475,6 @@ int pinpad_getline (int msg_code, uint32_t timeout_usec);
#endif
extern uint8_t _regnual_start, __heap_end__[];
extern uint8_t _regnual_start[], __heap_end__[];
uint8_t * sram_address (uint32_t offset);

View File

@@ -503,8 +503,8 @@ main (int argc, const char *argv[])
#ifdef FLASH_UPGRADE_SUPPORT
/* Set vector */
SCB->VTOR = (uintptr_t)&_regnual_start;
entry = calculate_regnual_entry_address (&_regnual_start);
SCB->VTOR = (uintptr_t)_regnual_start;
entry = calculate_regnual_entry_address (_regnual_start);
#ifdef DFU_SUPPORT
{
/* Use SYS at ORIGIN_REAL instead of the one at ORIGIN */

View File

@@ -227,7 +227,7 @@ static const uint8_t lun_table[] = { 0, 0, 0, 0, };
#endif
#ifdef FLASH_UPGRADE_SUPPORT
static const uint8_t *const mem_info[] = { &_regnual_start, __heap_end__, };
static const uint8_t *const mem_info[] = { _regnual_start, __heap_end__, };
#endif
#define USB_FSIJ_GNUK_MEMINFO 0
@@ -284,7 +284,7 @@ usb_setup (struct usb_dev *dev)
if (ccid_get_ccid_state () != CCID_STATE_EXITED)
return -1;
if (addr < &_regnual_start || addr + arg->len > __heap_end__)
if (addr < _regnual_start || addr + arg->len > __heap_end__)
return -1;
if (arg->index + arg->len < 256)