static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int count)
{
- /* Substitutes variables into cp2, based on string cp1, and assuming cp2 to be
- zero-filled */
+ /* Substitutes variables into cp2, based on string cp1, cp2 NO LONGER NEEDS TO BE ZEROED OUT!!!! */
char *cp4;
const char *tmp, *whereweare;
int length, offset, offset2, isfunction;
char *vars, *vare;
int pos, brackets, needsub, len;
+ *cp2 = 0; /* just in case nothing ends up there */
whereweare=tmp=cp1;
while (!ast_strlen_zero(whereweare) && count) {
/* Assume we're copying the whole remaining string */
count -= pos;
cp2 += pos;
whereweare += pos;
+ *cp2 = 0;
}
if (nextvar) {
vare++;
}
if (brackets)
- ast_log(LOG_NOTICE, "Error in extension logic (missing '}')\n");
+ ast_log(LOG_WARNING, "Error in extension logic (missing '}')\n");
len = vare - vars - 1;
/* Skip totally over variable string */
if (!ltmp)
ltmp = alloca(VAR_BUF_SIZE);
- memset(ltmp, 0, VAR_BUF_SIZE);
pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1);
vars = ltmp;
} else {
memcpy(cp2, cp4, length);
count -= length;
cp2 += length;
+ *cp2 = 0;
}
} else if (nextexp) {
/* We have an expression. Find the start and end, and determine
needsub = 0;
/* Find the end of it */
- while(brackets && *vare) {
+ while (brackets && *vare) {
if ((vare[0] == '$') && (vare[1] == '[')) {
needsub++;
brackets++;
vare++;
}
if (brackets)
- ast_log(LOG_NOTICE, "Error in extension logic (missing ']')\n");
+ ast_log(LOG_WARNING, "Error in extension logic (missing ']')\n");
len = vare - vars - 1;
/* Skip totally over expression */
if (!ltmp)
ltmp = alloca(VAR_BUF_SIZE);
- memset(ltmp, 0, VAR_BUF_SIZE);
pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1);
vars = ltmp;
} else {
ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2);
count -= length;
cp2 += length;
+ *cp2 = 0;
}
}
}