[PATCH 17/19] Set padding bytes to 0 in WriteToClient

Alan Coopersmith alan.coopersmith at oracle.com
Sun Jun 24 10:25:24 PDT 2012


Clear them out when needed instead of leaving whatever values were
present in previously sent messages.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 os/io.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/os/io.c b/os/io.c
index b67a5f3..f71ef56 100644
--- a/os/io.c
+++ b/os/io.c
@@ -815,7 +815,23 @@ WriteToClient(ClientPtr who, int count, const void *__buf)
     NewOutputPending = TRUE;
     FD_SET(oc->fd, &OutputPending);
     memmove((char *) oco->buf + oco->count, buf, count);
-    oco->count += count + padBytes;
+    oco->count += count;
+    switch (padBytes) {
+    case 0:
+        /* no padding needed */
+        break;
+    case 3:
+        oco->buf[oco->count++] = 0;
+        /* FALLTHROUGH */
+    case 2:
+        oco->buf[oco->count++] = 0;
+        /* FALLTHROUGH */
+    case 1:
+        oco->buf[oco->count++] = 0;
+        break;
+    default:
+        BUG_WARN(padBytes > 3);
+    }
     return count;
 }
 
-- 
1.7.9.2



More information about the xorg-devel mailing list