Limit a usbgecko uploaded binary to 20MB.

This commit is contained in:
dhewg 2009-04-17 00:09:17 +02:00 committed by bushing
parent f28f26c791
commit 5470c9a124

View File

@ -244,6 +244,8 @@ int gecko_printf(const char *fmt, ...)
#define GECKO_STATE_RECEIVE_BUFFER_SIZE 1 #define GECKO_STATE_RECEIVE_BUFFER_SIZE 1
#define GECKO_STATE_RECEIVE_BUFFER 2 #define GECKO_STATE_RECEIVE_BUFFER 2
#define GECKO_BUFFER_MAX (20 * 1024 * 1024)
static u32 _gecko_cmd = 0; static u32 _gecko_cmd = 0;
static u32 _gecko_cmd_start_time = 0; static u32 _gecko_cmd_start_time = 0;
static u32 _gecko_state = GECKO_STATE_NONE; static u32 _gecko_state = GECKO_STATE_NONE;
@ -311,6 +313,9 @@ void gecko_timer(void) {
_gecko_receive_left--; _gecko_receive_left--;
if (!_gecko_receive_left) { if (!_gecko_receive_left) {
if (_gecko_receive_len > GECKO_BUFFER_MAX)
goto cleanup;
_gecko_state = GECKO_STATE_RECEIVE_BUFFER; _gecko_state = GECKO_STATE_RECEIVE_BUFFER;
_gecko_receive_left = _gecko_receive_len; _gecko_receive_left = _gecko_receive_len;