octoi: only memcpy() if it is present in _octoi_tx_echo()

If the caller specifies zero-length data or a NULL pointer, don't
attempt to call memcpy() on that.

Change-Id: I5f5ed937643162d6ef6ce0cf2908432c007943c1
This commit is contained in:
Harald Welte 2022-04-30 12:19:24 +02:00
parent 0d813b5947
commit 18a05ecd7c
1 changed files with 2 additions and 1 deletions

View File

@ -130,7 +130,8 @@ static int _octoi_tx_echo(struct octoi_peer *peer, bool is_req, uint16_t seq_nr,
} u;
u.echo.seq_nr = htons(seq_nr);
memcpy(u.echo.data, data, data_len);
if (data && data_len)
memcpy(u.echo.data, data, data_len);
if (is_req)
msgt = E1OIP_MSGT_ECHO_REQ;