OSSP CVS Repository

ossp - Check-in [861]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 861
Date: 2001-Sep-05 15:33:55 (local)
2001-Sep-05 13:33:55 (UTC)
User:rse
Branch:
Comment: make sure logging message has a trailing newline
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_stream.c      1.11 -> 1.12     11 inserted, 1 deleted

ossp-pkg/l2/l2_stream.c 1.11 -> 1.12

--- l2_stream.c  2001/09/05 07:38:04     1.11
+++ l2_stream.c  2001/09/05 13:33:55     1.12
@@ -168,12 +168,22 @@
     
     /* format message */
     vfmt.curpos = st->message;
-    vfmt.endpos = st->message+ L2_MAX_MSGSIZE;
+    vfmt.endpos = st->message + L2_MAX_MSGSIZE;
     vfmt.data[0].vp = st;
     vfmt.flush  = l2_stream_vlog_flush;
     vfmt.format = l2_stream_vlog_format;
     if ((len = l2_util_format(&vfmt, fmt, ap)) == -1)
         return L2_ERROR;
+    if (len == 0)
+        return L2_ERROR;
+
+    /* make sure a trailing newline exists */
+    if (st->message[len-1] != '\n') {
+        if (len == L2_MAX_MSGSIZE)
+            return L2_ERROR;
+        st->message[len++] = '\n';
+        st->message[len]   = '\0';
+    }
 
     rv = L2_OK;
     for (i = 0; i < L2_MAX_CHANNELS && st->channels[i].ch != NULL; i++) {

CVSTrac 2.0.1