diff options
author | Francesco Fusco <ffusco@redhat.com> | 2013-12-19 18:16:24 +0100 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2014-01-13 13:25:57 -0800 |
commit | 2e275c0e00adced5dab256e5ccd1b4ae60ec127d (patch) | |
tree | b33dfdcf0eb91bd5beeb70757c7e68fe7b3b4e42 /lib/sflow_receiver.c | |
parent | 7868fbc6c97c2a69ff2b9bb2c00f46675e9f721b (diff) | |
download | openvswitch-2e275c0e00adced5dab256e5ccd1b4ae60ec127d.tar.gz |
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 <ffusco@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/sflow_receiver.c')
-rw-r--r-- | lib/sflow_receiver.c | 4 |
1 files changed, 4 insertions, 0 deletions
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) { |