diff --git a/src/elogd.c b/src/elogd.c
index 5db1325c..861e8a9c 100755
--- a/src/elogd.c
+++ b/src/elogd.c
@@ -7694,7 +7694,7 @@ void xmlencode(char *text)
/*------------------------------------------------------------------*/
-void strencode2(char *b, char *text)
+void strencode2(char *b, char *text, int size)
{
int i;
@@ -7702,21 +7702,33 @@ void strencode2(char *b, char *text)
for (i = 0; i < (int) strlen(text); i++) {
switch (text[i]) {
case '\n':
+ if (strlen(b)+5 >= (unsigned int)size)
+ return;
strcat(b, "
\n");
break;
case '<':
+ if (strlen(b)+4 >= (unsigned int)size)
+ return;
strcat(b, "<");
break;
case '>':
+ if (strlen(b)+4 >= (unsigned int)size)
+ return;
strcat(b, ">");
break;
case '&':
+ if (strlen(b)+5 >= (unsigned int)size)
+ return;
strcat(b, "&");
break;
case '\"':
+ if (strlen(b)+6 >= (unsigned int)size)
+ return;
strcat(b, """);
break;
default:
+ if (strlen(b)+1 >= (unsigned int)size)
+ return;
sprintf(b + strlen(b), "%c", text[i]);
}
}
@@ -8960,7 +8972,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf("\n");
script[0] = 0;
- if (isparam("inlineatt"))
+ if (isparam("inlineatt") && *getparam("inlineatt"))
strcpy(script, " OnLoad=\"document.form1.Text.focus();\"");
if (getcfg(lbs->name, "Use Lock", str, sizeof(str)) && atoi(str) == 1)
@@ -9175,7 +9187,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf("\n", str, attr_options[index][i]);
}
} else {
- strencode2(str, attrib[index]);
+ strencode2(str, attrib[index], sizeof(str));
rsprintf("\n", ua, str);
}
} else {
@@ -9251,7 +9263,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
/* show normal edit field */
rsprintf("