Sanitize error text to reduce TCL errors

This commit is contained in:
Douglas Clowes
2014-04-04 11:54:21 +11:00
parent f9bff7f4f2
commit 1692e0d4d4

View File

@ -402,6 +402,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
char *errorScript = NULL;
char *send = NULL;
int i;
int j;
SConnection *con;
char eprop[80];
char msg[1024];
@ -516,6 +517,21 @@ static char *SctActionHandler(void *actionData, char *lastReply,
if (strcasecmp(data->name, "read") == 0) {
SetHdbProperty(node, "geterror", result);
}
/* Sanitize the text to reduce TCL problems with unbalanced and substituted items */
for (j = 0; msg[j]; ++j) {
switch (msg[j]) {
case '{':
case '}':
case '[':
case ']':
case '<':
case '>':
case '\'':
case '"':
case '$':
msg[j] = '_';
}
}
SetHdbProperty(node, eprop, msg);
blank = strchr(origScript, ' ');
if (blank != NULL) {
@ -531,6 +547,21 @@ static char *SctActionHandler(void *actionData, char *lastReply,
}
cnt++;
snprintf(msg, sizeof msg, "%dx {%s}: %s", cnt, origScript, result);
/* Sanitize the text to reduce TCL problems with unbalanced and substituted items */
for (j = 0; msg[j]; ++j) {
switch (msg[j]) {
case '{':
case '}':
case '[':
case ']':
case '<':
case '>':
case '\'':
case '"':
case '$':
msg[j] = '_';
}
}
SetHdbProperty(node, eprop, msg);
send = NULL;
free(script);