Index: ossp-pkg/l2/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/l2/ChangeLog,v rcsdiff -q -kk '-r1.8' '-r1.9' -u '/v/ossp/cvs/ossp-pkg/l2/ChangeLog,v' 2>/dev/null --- ChangeLog 2003/11/06 11:59:02 1.8 +++ ChangeLog 2003/11/06 15:31:47 1.9 @@ -11,6 +11,13 @@ Changes between 0.9.4 and 0.9.5 (25-Sep-2003 to ??-???-????) + *) Fix Problem where l2 does not terminate a message when it + contains a \n so if previous message was longer the part between + \n and the end of the previous message is repeated in the current + message. + http://cvs.ossp.org/tktview?tn=23 + [Thomas Lotterer ] + *) Added bison-locations option to scanner, fixing the missing reentrant yylloc with flex-2.5.31. [Michael Schloh ] Index: ossp-pkg/l2/TODO RCS File: /v/ossp/cvs/ossp-pkg/l2/TODO,v rcsdiff -q -kk '-r1.61' '-r1.62' -u '/v/ossp/cvs/ossp-pkg/l2/TODO,v' 2>/dev/null --- TODO 2003/11/06 12:58:21 1.61 +++ TODO 2003/11/06 15:31:47 1.62 @@ -10,13 +10,6 @@ ==== 20030611 thl - Fix Problem where l2 does not terminate a message when - it contains a \n so if previous message was longer the - part between \n and the end of the previous message is - repeated in the current message. - http://cvs.ossp.org/tktview?tn=23 - -20030611 thl Fix Problem where l2 is not thread safe when multiple threads use the same env as is true with with fsl. http://cvs.ossp.org/tktview?tn=24 Index: ossp-pkg/l2/l2_channel.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_channel.c,v rcsdiff -q -kk '-r1.32' '-r1.33' -u '/v/ossp/cvs/ossp-pkg/l2/l2_channel.c,v' 2>/dev/null --- l2_channel.c 2003/02/13 15:37:28 1.32 +++ l2_channel.c 2003/11/06 15:31:47 1.33 @@ -582,18 +582,26 @@ vfmt.data[1].i = L2_ERR_FMT; vfmt.flush = l2_channel_vlog_flush; vfmt.format = l2_channel_vlog_format; - if ((len = l2_util_format(&vfmt, fmt, ap)) == -1) + len = l2_util_format(&vfmt, fmt, ap); + + /* check for formatting error including buffer overrun */ + if (len == -1) return (l2_result_t)(vfmt.data[1].i); + + /* check for formatting led to completely empty message */ if (len == 0) return L2_ERR_FMT; - /* make sure a trailing newline exists */ - if (env->message[len-1] != '\n') { - if (len == L2_MAX_MSGSIZE) - return L2_ERR_MEM; + /* check for formatting led to newline-only message */ + if (len == 1 && env->message[len] == '\n') + return L2_ERR_FMT; + + /* make sure a trailing newline exists; L2_MSG_BUFSIZE has room for CR/LF */ + if (env->message[len-1] != '\n') env->message[len++] = '\n'; - env->message[len] = '\0'; - } + + /* make sure a trailing NUL exists; L2_MSG_BUFSIZE has room for NUL */ + env->message[len] = '\0'; /* write message to channel */ rv = L2_OK; Index: ossp-pkg/l2/l2_p.h RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_p.h,v rcsdiff -q -kk '-r1.34' '-r1.35' -u '/v/ossp/cvs/ossp-pkg/l2/l2_p.h,v' 2>/dev/null --- l2_p.h 2003/01/06 11:41:52 1.34 +++ l2_p.h 2003/11/06 15:31:47 1.35 @@ -73,7 +73,9 @@ cu(value) /* some hard-coded sizes :-( */ -#define L2_MAX_MSGSIZE 4096 +#define L2_MAX_OUTSIZE 4098 /* this value is for compatiblity with previous versions of L2 */ +#define L2_MAX_MSGSIZE L2_MAX_OUTSIZE - 2 /* leave room for CR/LF although OSSP/UNIX use LF only */ +#define L2_MSG_BUFSIZE L2_MAX_OUTSIZE + 1 /* reserve space for convenient trailing NUL */ #define L2_MAX_FORMATTERS 128 #define L2_MAX_HANDLERS 128 #define L2_BROKEN_TIMER -1 @@ -112,7 +114,7 @@ int interval; l2_formatter_entry_t formatters[L2_MAX_FORMATTERS]; l2_handler_t *handlers[L2_MAX_HANDLERS]; - char message[L2_MAX_MSGSIZE]; + char message[L2_MSG_BUFSIZE]; char szError[1024]; char szErrorInfo[512]; l2_result_t rvErrorInfo;