Mercurial > ecos
changeset 2010:2379473fdc8d
* src/fconfig.c: (get_config): Verify the length of the script is
less than MAX_SCRIPT_LENGTH.
| author | asl |
|---|---|
| date | Wed, 06 Jul 2005 18:41:21 +0000 |
| parents | a6e5ade47511 |
| children | 662e1b34b811 |
| files | packages/redboot/current/ChangeLog packages/redboot/current/src/fconfig.c |
| diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,8 @@ +2005-07-06 Isaac Claymore <iclaymore@gmail.com> + + * src/fconfig.c: (get_config): Verify the length of the script is + less than MAX_SCRIPT_LENGTH. + 2005-06-29 Andrew Lunn <andrew.lunn@ascom.ch> * doc/redboot_cmds.sgml:
--- a/packages/redboot/current/src/fconfig.c +++ b/packages/redboot/current/src/fconfig.c @@ -262,7 +262,7 @@ get_config(unsigned char *dp, char *titl char *esp; #endif void *val_ptr; - int type; + int type, script_len; if (CONFIG_OBJECT_ENABLE_KEYLEN(dp)) { flash_get_config(CONFIG_OBJECT_ENABLE_KEY(dp), &enable, CONFIG_BOOL); @@ -433,6 +433,7 @@ get_config(unsigned char *dp, char *titl case CONFIG_SCRIPT: // Assume it always changes sp = (unsigned char *)val_ptr; + script_len = 0; diag_printf("Enter script, terminate with empty line\n"); while (true) { *sp = '\0'; @@ -440,6 +441,12 @@ get_config(unsigned char *dp, char *titl ret = _rb_gets(line, sizeof(line), 0); if (ret < 0) return CONFIG_ABORT; if (strlen(line) == 0) break; + script_len += strlen(line) + 1; + if (script_len > config_length(CONFIG_SCRIPT)) { + diag_printf("script longer than %d not allowed!\n", + config_length(CONFIG_SCRIPT)); + return CONFIG_ABORT; + } lp = line; while (*lp) { *sp++ = *lp++;
