diff options
author | Evan Huus <eapache@gmail.com> | 2013-10-17 02:43:21 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2013-10-17 02:43:21 +0000 |
commit | 934bfff0030150f808e874b7424e635abcced9c1 (patch) | |
tree | 1182a062ef0d438a3664397a5c93945a69ba084a /epan/tvbuff.c | |
parent | 747f1409a158d9c8569e32ac67e84c55582eb5de (diff) |
Temporarily revert r52651 it caused a regression when trying to tvb_memcpy from
a negative offset (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9277)
svn path=/trunk/; revision=52658
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 43deee7b16..b967e81f11 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -709,23 +709,6 @@ guint8_pbrk(const guint8* haystack, size_t haystacklen, const guint8 *needles, g /************** ACCESSORS **************/ -inline static void * -_tvb_memcpy(tvbuff_t *tvb, void *target, guint abs_offset, guint abs_length) -{ - if (tvb->real_data) { - return memcpy(target, tvb->real_data + abs_offset, abs_length); - } - - if (tvb->ops->tvb_memcpy) - return tvb->ops->tvb_memcpy(tvb, target, abs_offset, abs_length); - - /* XXX, fallback to slower method */ - - DISSECTOR_ASSERT_NOT_REACHED(); - return NULL; - -} - void * tvb_memcpy(tvbuff_t *tvb, void *target, const gint offset, size_t length) { @@ -747,7 +730,17 @@ tvb_memcpy(tvbuff_t *tvb, void *target, const gint offset, size_t length) DISSECTOR_ASSERT(length <= 0x7FFFFFFF); check_offset_length(tvb, offset, (gint) length, &abs_offset, &abs_length); - return _tvb_memcpy(tvb, target, abs_offset, abs_length); + if (tvb->real_data) { + return memcpy(target, tvb->real_data + abs_offset, abs_length); + } + + if (tvb->ops->tvb_memcpy) + return tvb->ops->tvb_memcpy(tvb, target, abs_offset, abs_length); + + /* XXX, fallback to slower method */ + + DISSECTOR_ASSERT_NOT_REACHED(); + return NULL; } @@ -777,7 +770,7 @@ tvb_memdup(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, size_t len check_offset_length(tvb, offset, (gint) length, &abs_offset, &abs_length); duped = wmem_alloc(scope, abs_length); - return _tvb_memcpy(tvb, duped, abs_offset, abs_length); + return tvb_memcpy(tvb, duped, abs_offset, abs_length); } @@ -1216,7 +1209,7 @@ tvb_get_ntohguid(tvbuff_t *tvb, const gint offset, e_guid_t *guid) guid->data1 = tvb_get_ntohl(tvb, offset); guid->data2 = tvb_get_ntohs(tvb, offset + 4); guid->data3 = tvb_get_ntohs(tvb, offset + 6); - _tvb_memcpy(tvb, guid->data4, offset + 8, sizeof guid->data4); + tvb_memcpy(tvb, guid->data4, offset + 8, sizeof guid->data4); } void @@ -1226,7 +1219,7 @@ tvb_get_letohguid(tvbuff_t *tvb, const gint offset, e_guid_t *guid) guid->data1 = tvb_get_letohl(tvb, offset); guid->data2 = tvb_get_letohs(tvb, offset + 4); guid->data3 = tvb_get_letohs(tvb, offset + 6); - _tvb_memcpy(tvb, guid->data4, offset + 8, sizeof guid->data4); + tvb_memcpy(tvb, guid->data4, offset + 8, sizeof guid->data4); } /* @@ -1921,7 +1914,7 @@ tvb_get_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, const tvb_ensure_bytes_exist(tvb, offset, length); /* make sure length = -1 fails */ strbuf = (guint8 *)wmem_alloc(scope, length + 1); - _tvb_memcpy(tvb, strbuf, offset, length); + tvb_memcpy(tvb, strbuf, offset, length); strbuf[length] = '\0'; return strbuf; } |