aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--listbas.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/listbas.c b/listbas.c
index 515d264..4a6c0a8 100644
--- a/listbas.c
+++ b/listbas.c
@@ -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;
}
}