From b8e8579df592c050dfab2dc45f5004b67dbb965e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rami=20Ylim=C3=A4ki?= Date: Wed, 9 Mar 2011 15:45:40 +0200 Subject: [PATCH] xkb: Initialize pad bytes sent in replies of geometry requests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Valgrind complains about uninitialized data being written to clients. Reviewed-by: Erkki Seppälä Signed-off-by: Rami Ylimäki Reviewed-by: Daniel Stone Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer (cherry picked from commit dc9ce695a69ca0787f58f8d160212a7a41acb703) --- xkb/xkb.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index 63eb46a9e..a8d0e801c 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -4310,7 +4310,7 @@ ProcXkbSetNames(ClientPtr client) static char * XkbWriteCountedString(char *wire,char *str,Bool swap) { - CARD16 len,*pLen; + CARD16 len,*pLen, paddedLen; if (!str) return wire; @@ -4322,8 +4322,9 @@ XkbWriteCountedString(char *wire,char *str,Bool swap) register int n; swaps(pLen,n); } - memcpy(&wire[2],str,len); - wire+= ((2+len+3)/4)*4; + paddedLen= pad_to_int32(sizeof(len)+len)-sizeof(len); + strncpy(&wire[sizeof(len)],str,paddedLen); + wire+= sizeof(len)+paddedLen; return wire; } @@ -4434,6 +4435,7 @@ xkbShapeWireDesc * shapeWire; if (shape->approx!=NULL) shapeWire->approxNdx= XkbOutlineIndex(shape,shape->approx); else shapeWire->approxNdx= XkbNoShape; + shapeWire->pad= 0; if (swap) { register int n; swapl(&shapeWire->name,n); @@ -4446,6 +4448,7 @@ xkbShapeWireDesc * shapeWire; olWire= (xkbOutlineWireDesc *)wire; olWire->nPoints= ol->num_points; olWire->cornerRadius= ol->corner_radius; + olWire->pad= 0; wire= (char *)&olWire[1]; ptWire= (xkbPointWireDesc *)wire; for (p=0,pt=ol->points;pnum_points;p++,pt++) { @@ -4559,6 +4562,8 @@ xkbOverlayWireDesc * olWire; olWire= (xkbOverlayWireDesc *)wire; olWire->name= ol->name; olWire->nRows= ol->num_rows; + olWire->pad1= 0; + olWire->pad2= 0; if (swap) { register int n; swapl(&olWire->name,n); @@ -4571,6 +4576,7 @@ xkbOverlayWireDesc * olWire; rowWire= (xkbOverlayRowWireDesc *)wire; rowWire->rowUnder= row->row_under; rowWire->nKeys= row->num_keys; + rowWire->pad1= 0; wire= (char *)&rowWire[1]; for (k=0,key=row->keys;knum_keys;k++,key++) { xkbOverlayKeyWireDesc * keyWire;