From: Francesco Fusco Date: Thu, 19 Dec 2013 17:16:24 +0000 (+0100) Subject: sFlow: clear the padding X-Git-Tag: v2.1.0~45 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=1497929329faed1d840c1539b9e69f78bd26e756 sFlow: clear the padding putString pads the string to the 4-byte boundary without clearing the "padded" memory. This patch simply set the padding to zero. Signed-off-by: Francesco Fusco Signed-off-by: Ben Pfaff --- diff --git a/lib/sflow_receiver.c b/lib/sflow_receiver.c index 3e5a67a06..e6fc9a7f9 100644 --- a/lib/sflow_receiver.c +++ b/lib/sflow_receiver.c @@ -198,6 +198,10 @@ inline static void putString(SFLReceiver *receiver, SFLString *s) putNet32(receiver, s->len); memcpy(receiver->sampleCollector.datap, s->str, s->len); receiver->sampleCollector.datap += (s->len + 3) / 4; /* pad to 4-byte boundary */ + if ((s->len % 4) != 0){ + u_int8_t padding = 4 - (s->len % 4); + memset(((u_int8_t*)receiver->sampleCollector.datap)-padding, 0, padding); + } } inline static u_int32_t stringEncodingLength(SFLString *s) {