diff options
Diffstat (limited to 'replay.c')
-rw-r--r-- | replay.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -343,6 +343,17 @@ int lastspokesecondsago(char *nick, char *basedir) { // With the ":foo!bar@baz "prefix being important. // Returns 1 on success or 0 on failure. int writereplayline(char *str, char *basedir) { + // Ensure "str" isn't too long + if (strlen(str) >= MAXCHAR) { + // String is too long! + debugprint(DEBUG_CRIT, "writereplayline(): str '%s' was too long (%d out of a max of %d characters).\n", str, strlen(str), MAXCHAR - 1); + return 0; + } else if (strlen(str) >= MAXCHAR - 2 && str[strlen(str) - 1] != '\r' && str[strlen(str)] != '\n') { + // Ensure string can fit CRLF at the end if it doesn't already have it + debugprint(DEBUG_CRIT, "writereplayline(): non-CRLF message too long to append CRLF to.\n"); + return 0; + } + FILE *fp; char line[MAXCHAR]; char filename[PATH_MAX]; |