diff options
author | B. Watson <urchlay@slackware.uk> | 2024-07-13 02:51:08 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-07-13 02:51:08 -0400 |
commit | e7ad411b1a8fcd7f3cdf4a81a05aa9fc19575211 (patch) | |
tree | d84996016977a48fb33f2f19f725181fe628b8ba | |
parent | 17ee646ccd25daa83dfd363ccbe247a5b93be806 (diff) | |
download | bw-atari8-tools-e7ad411b1a8fcd7f3cdf4a81a05aa9fc19575211.tar.gz |
listbas: avoid buffer overflow if too many spaces in LISTBAS_OPTS.
-rw-r--r-- | listbas.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -140,10 +140,12 @@ void parse_args(int argc, char **argv, int from_env) { } } +#define ENV_MAX_ARGS 64 + /* make a fake argv and argc */ void parse_env_args(void) { int fargc; - char *fargv[10]; + char *fargv[ENV_MAX_ARGS + 1]; char *env, *p; env = getenv(ENV_OPTS); @@ -159,6 +161,10 @@ void parse_env_args(void) { for(p = env; *p; p++) { if(*p == ' ' || *p == '\t') { *p = '\0'; + if(fargc == ENV_MAX_ARGS) { + fprintf(stderr, "%s: too many spaces in LISTBAS_OPTS (max %d)\n", self, ENV_MAX_ARGS - 1); + break; + } fargv[fargc++] = p + 1; } } |