aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2019-11-21 14:26:36 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2019-11-21 14:28:29 +0400
commitd0e9738408ffa72626693ca5c28e8f80ea162ce4 (patch)
treeffa7a4125ca4165a41316fc2d1d3dea4b5966eb1
parentd171af3732a0610a25334b06b77fa547bd677918 (diff)
downloadslirp-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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/sbuf.c b/src/sbuf.c
index 0569c34..3f20729 100644
--- a/src/sbuf.c
+++ b/src/sbuf.c
@@ -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 */