]> git.itanic.dy.fi Git - rrdd/commit
network_parser: Sanitize buffer state between calls and between parsed lines
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 1 Mar 2023 16:09:35 +0000 (18:09 +0200)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 1 Mar 2023 16:09:35 +0000 (18:09 +0200)
commit3a3afa0ea5bc6ff6b8a5c3746f7d8e6617f2bfca
tree6531edb97dec2a68ae554e0c3f349ca89a56de34
parentfded2f3ea2ef4863bdffcfa46302811da1f79c49
network_parser: Sanitize buffer state between calls and between parsed lines

Whenever we have finished parsing a line, the destination buffer must
be zeroed out to prevent stale data from corrupting the data.

Once data is copied from the receive buffer to the last_line buffer
and the receive buffer is moved back to the beginning, we must zero
out the old data at the end of the buffer to prevent corrupting any
new data. This can happen if we receive multiple lines in one recv()
call.

When we have finished handling one set of data, we should clear the
buffer state and data to prevent any stale data from corrupting the
data on next call. This could happen for example if the TCP transfer
is interrupted for any reason and we don't receive comlete line for
any reason.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
network_parser.c