Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/famicom-dumper-writer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2023-01-15 19:57:40 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2023-01-15 19:57:40 +0300
commit48406ee6c5b3f600b1b63cfa6d5d6b7da7ddff6b (patch)
treeb70921cfd463a8ba1956b9ef4aa3c432c31c0d4f
parentd8427bfae5da9de0915c41ca6a95bd778b21dea3 (diff)
Buffer overflow fix
-rw-r--r--STM32/Core/Inc/comm.h2
-rw-r--r--STM32/Core/Inc/dumper.h2
-rw-r--r--STM32/Core/Src/comm.c8
-rw-r--r--STM32/Core/Src/main.c1
4 files changed, 7 insertions, 6 deletions
diff --git a/STM32/Core/Inc/comm.h b/STM32/Core/Inc/comm.h
index b585ccf..e929655 100644
--- a/STM32/Core/Inc/comm.h
+++ b/STM32/Core/Inc/comm.h
@@ -3,7 +3,7 @@
#include <inttypes.h>
-#define RECV_BUFFER_SIZE 1024 * 54
+#define RECV_BUFFER_SIZE 1024 * 50
#define SEND_BUFFER_SIZE 64
#define SEND_TIMEOUT 1000
diff --git a/STM32/Core/Inc/dumper.h b/STM32/Core/Inc/dumper.h
index 28fe384..fd1201f 100644
--- a/STM32/Core/Inc/dumper.h
+++ b/STM32/Core/Inc/dumper.h
@@ -3,7 +3,7 @@
#define PROTOCOL_VERSION 5
#define FIRMWARE_VERSION_MAJOR 3
-#define FIRMWARE_VERSION_MINOR 2
+#define FIRMWARE_VERSION_MINOR 3
#define FIRMWARE_VERSION_SUFFIX 0
#define HARDWARE_VERSION_ADDRESS 0x08070000 - 2048
#define HARDWARE_VERSION ((volatile uint8_t*)(HARDWARE_VERSION_ADDRESS))
diff --git a/STM32/Core/Src/comm.c b/STM32/Core/Src/comm.c
index df78157..aaf6698 100644
--- a/STM32/Core/Src/comm.c
+++ b/STM32/Core/Src/comm.c
@@ -45,12 +45,14 @@ static void comm_send_and_calc(uint8_t data)
static uint8_t check_send_buffer()
{
uint8_t ok = 1;
- if (comm_send_pos >= comm_send_length)
+ if (send_buffer_pos >= sizeof(send_buffer))
{
- send_buffer[send_buffer_pos++] = comm_send_crc;
ok &= comm_flush();
- } else if (send_buffer_pos >= sizeof(send_buffer))
+ if (!ok) return ok;
+ }
+ if (comm_send_pos >= comm_send_length)
{
+ send_buffer[send_buffer_pos++] = comm_send_crc;
ok &= comm_flush();
}
return ok;
diff --git a/STM32/Core/Src/main.c b/STM32/Core/Src/main.c
index 4036077..00df330 100644
--- a/STM32/Core/Src/main.c
+++ b/STM32/Core/Src/main.c
@@ -79,7 +79,6 @@ static void MX_TIM4_Init(void);
/* USER CODE BEGIN 0 */
int _write(int file, char *ptr, int len)
{
- /* Implement your write code here, this is used by puts and printf for example */
for (int i = 0; i < len; i++)
ITM_SendChar((*ptr++));
return len;