diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-11-21 14:26:36 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-11-21 14:28:29 +0400 |
commit | d0e9738408ffa72626693ca5c28e8f80ea162ce4 (patch) | |
tree | ffa7a4125ca4165a41316fc2d1d3dea4b5966eb1 | |
parent | d171af3732a0610a25334b06b77fa547bd677918 (diff) | |
download | slirp-d0e9738408ffa72626693ca5c28e8f80ea162ce4.zip slirp-d0e9738408ffa72626693ca5c28e8f80ea162ce4.tar.gz slirp-d0e9738408ffa72626693ca5c28e8f80ea162ce4.tar.bz2 |
sbuf: remove unused and undefined sbcopy() path
The only sbcopy() caller is tcp_output(). There, len is constrained to
be 0 <= len <= sb_cc. Let's add some assert to avoid potential
undefined behaviour (the function didn't return the actual number of
bytes copied).
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r-- | src/sbuf.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -168,13 +168,14 @@ void sbcopy(struct sbuf *sb, int off, int len, char *to) { char *from; + g_assert(len >= 0); + g_assert(len <= sb->sb_cc); + from = sb->sb_rptr + off; if (from >= sb->sb_data + sb->sb_datalen) from -= sb->sb_datalen; if (from < sb->sb_wptr) { - if (len > sb->sb_cc) - len = sb->sb_cc; memcpy(to, from, len); } else { /* re-use off */ |