jcs
/subtext
/amendments
/94
session: Fix "then" of ternary operator in session_expand_var
jcs made amendment 94 over 2 years ago
--- session.c Tue Apr 12 16:37:50 2022
+++ session.c Thu Apr 14 16:04:15 2022
@@ -914,7 +914,7 @@ expand_var:
matchvar[sep] = '\0';
} else {
/* copy from after the "then" and : */
- strlcpy(matchvar, curvarpos + sep, sizeof(matchvar));
+ strlcpy(matchvar, curvarpos + sep + 1, sizeof(matchvar));
}
sep = strlen(matchvar);
@@ -957,6 +957,9 @@ session_expand_var(struct session *session, char *ivar
pad = true;
varlen = strlen(var);
} else {
+ while (ivar[0] == ' ')
+ ivar++;
+
varlen = strlcpy(var, ivar, sizeof(var));
retsize = sizeof(retval);
}
@@ -995,6 +998,10 @@ session_expand_var(struct session *session, char *ivar
varlen = retsize;
strlcpy(retval, var + 1, varlen);
retlen = varlen - 1;
+ } else {
+ /* shrug */
+ strlcpy(retval, var, varlen);
+ retlen = varlen;
}
if (pad && retlen < retsize) {