FreeCalypso > hg > freecalypso-hwlab
diff fteeprom/ftee-gen2232c.c @ 34:ae48b7d69744
ftee-gen2232c: added guard against strings overflowing EEPROM space
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 Apr 2019 18:50:33 +0000 |
parents | 16b625911e19 |
children | ea0b5aed9a9c |
line wrap: on
line diff
--- a/fteeprom/ftee-gen2232c.c Sun Apr 21 17:51:32 2019 +0000 +++ b/fteeprom/ftee-gen2232c.c Sun Apr 21 18:50:33 2019 +0000 @@ -95,6 +95,10 @@ { unsigned longlen, startptr; + if (63 - eeprom_string_ptr < strlen(str) + 1) { + fprintf(stderr, "error: strings are too long\n"); + exit(1); + } longlen = strlen(str) * 2 + 2; startptr = eeprom_string_ptr; eeprom[eeprom_string_ptr++] = 0x0300 | longlen;