Mercurial > ecos-v3_0-branch
diff packages/redboot/current/src/fconfig.c @ 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 | b9ae2f90a53e |
| children | 5c5e93c863ac |
line wrap: on
line diff
--- 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++;
