OSSP CVS Repository

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

Check-in Number: 729
Date: 2001-Aug-22 20:12:16 (local)
2001-Aug-22 18:12:16 (UTC)
User:ms
Branch:
Comment: When buffer will overflow, it should fail first. Also, when buffer gets a write message it should not pass it downstream. The buffer writes data further downstream only when it is flushed (either by the user or implicitly.)
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_ch_buffer.c      1.5 -> 1.6     3 inserted, 6 deleted

ossp-pkg/l2/l2_ch_buffer.c 1.5 -> 1.6

--- l2_ch_buffer.c       2001/08/15 10:36:03     1.5
+++ l2_ch_buffer.c       2001/08/22 18:12:16     1.6
@@ -92,12 +92,8 @@
     if ((cfg = (l2_ch_buffer_t *)ctx->vp) == NULL)
         return L2_ERROR;
 
-    if (bufsize > (cfg->bufsize - cfg->bufpos)) {
-        if (downstream != NULL)
-            if (l2_channel_write(downstream, cfg->buf, cfg->bufpos) == L2_ERROR)
-                return L2_ERROR;
-        cfg->bufpos = 0;
-    }
+    if (bufsize > (cfg->bufsize - cfg->bufpos))
+        return L2_ERROR; /* The buffer is too small */
 
     memcpy(cfg->buf+cfg->bufpos, buf, bufsize);
     cfg->bufpos += bufsize;
@@ -117,6 +113,7 @@
             if (l2_channel_write(downstream, cfg->buf, cfg->bufpos) == L2_ERROR)
                 return L2_ERROR;
         cfg->bufpos = 0;
+        bzero(cfg->buf, cfg->bufsize); /* Guard against improper usage */
     }
 
     if (downstream != NULL)

CVSTrac 2.0.1