diff --git a/man/remind.1 b/man/remind.1 index 834ee8a8..6edac1ab 100644 --- a/man/remind.1 +++ b/man/remind.1 @@ -2260,7 +2260,9 @@ The maximum number of iterations for the \fBSATISFY\fR clause .TP .B $MaxStringLen A limit on the longest string that \fBRemind\fR will allow you -to create. The default is 65535. +to create. The default is 65535. If you set \fB$MaxStringLen\fR to 0 +or to -1, then \fBremind\fR will allow you to create arbitrarily-long +strings, at least until it runs out of memory. .TP .B $MinsFromUTC The number of minutes between Universal Time Coordinated and local time. If @@ -3015,8 +3017,8 @@ not be executed. .PP If \fImaxlen\fR is specified, then \fBshell()\fR returns the first \fImaxlen\fR characters of output (rather than the first 511). If -\fImaxlen\fR is specified as a negative number, then \fIall\fR the -output from \fIcmd\fR is returned. +\fImaxlen\fR is specified as a negative number, then it defaults to +the value of the system variable \fB$MaxStringLen\fR. .RE .TP .B shellescape(s_str) diff --git a/src/expr.c b/src/expr.c index 766eccc1..483d1d1e 100644 --- a/src/expr.c +++ b/src/expr.c @@ -828,7 +828,7 @@ static int Add(void) v3.type = STR_TYPE; l1 = strlen(v1.v.str); l2 = strlen(v2.v.str); - if (MaxStringLen && (l1 + l2 > (size_t) MaxStringLen)) { + if (MaxStringLen > 0 && (l1 + l2 > (size_t) MaxStringLen)) { DestroyValue(v1); DestroyValue(v2); return E_STRING_TOO_LONG; } diff --git a/src/funcs.c b/src/funcs.c index 9ee89031..c0334b00 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -1572,6 +1572,15 @@ static int FShell(func_info *info) ASSERT_TYPE(1, INT_TYPE); maxlen = ARGV(1); } + + /* Don't allow maxlen to exceed the maximum length of + a string variable */ + if (MaxStringLen > 0) { + if (maxlen <= 0 || maxlen > MaxStringLen) { + maxlen = MaxStringLen; + } + } + fp = popen(ARGSTR(0), "r"); if (!fp) return E_IO_ERR; while (1) {