mirror of
https://github.com/ole00/afterburner.git
synced 2025-02-16 19:31:15 +00:00
PC app: fix serial port read buffer overflow
Overflow happened when verbose printouts were enabled in the Arduino sketch.
This commit is contained in:
parent
2754ff5c47
commit
79e33ab2a5
@ -50,7 +50,7 @@ To compile: gcc -g3 -O0 -o afterburner afterburner.c
|
|||||||
|
|
||||||
#define VERSION "v.0.5.8"
|
#define VERSION "v.0.5.8"
|
||||||
|
|
||||||
#define MAX_LINE 1024
|
#define MAX_LINE (16*1024)
|
||||||
|
|
||||||
#define MAXFUSES 30000
|
#define MAXFUSES 30000
|
||||||
#define GALBUFSIZE 65536
|
#define GALBUFSIZE 65536
|
||||||
@ -723,6 +723,10 @@ static int waitForSerialPrompt(char* buf, int bufSize, int maxDelay) {
|
|||||||
} else {
|
} else {
|
||||||
buf += readSize;
|
buf += readSize;
|
||||||
bufSize -= readSize;
|
bufSize -= readSize;
|
||||||
|
if (bufSize <= 0) {
|
||||||
|
printf("ERROR: serial port read buffer is too small!\nAre you dumping large amount of data?\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (printSerialWhileWaiting) {
|
if (printSerialWhileWaiting) {
|
||||||
bufPrint = printBuffer(bufPrint, readSize);
|
bufPrint = printBuffer(bufPrint, readSize);
|
||||||
@ -771,6 +775,9 @@ static int sendLine(char* buf, int bufSize, int maxDelay) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
total = waitForSerialPrompt(obuf, bufSize, (maxDelay < 0) ? 6 : maxDelay);
|
total = waitForSerialPrompt(obuf, bufSize, (maxDelay < 0) ? 6 : maxDelay);
|
||||||
|
if (total < 0) {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
obuf[total] = 0;
|
obuf[total] = 0;
|
||||||
obuf = stripPrompt(obuf);
|
obuf = stripPrompt(obuf);
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user