aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-10-17 18:30:51 +0100
committerJoão Valverde <j@v6e.pt>2022-10-18 19:51:38 +0100
commit4136b250c593da2ef8a4ef8444ce4b6ae23e30b3 (patch)
tree30de8ae4c6d07fc05c54c1fa2673e6d4bc738426 /epan/tvbuff.c
parente4d5a440144969493f01c20f23f11b0f59f2a5bc (diff)
epan: Rename tvb_get_nstringz0()
Rename tvb_get_nstringz0() to tvb_get_raw_bytes_as_stringz() to reflect the fact that this function does not return a string (UTF-8 internal text string). Remove tvb_get_stringz() because it is unused and just seems dangerous.
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 8b2ae215ec..81502d2531 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -3751,7 +3751,7 @@ tvb_get_stringz_enc(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, g
* including the terminating-NUL.
*/
static gint
-_tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer, gint *bytes_copied)
+_tvb_get_raw_bytes_as_stringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer, gint *bytes_copied)
{
gint stringlen;
guint abs_offset = 0;
@@ -3818,41 +3818,14 @@ _tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8*
return stringlen;
}
-/* Looks for a stringz (NUL-terminated string) in tvbuff and copies
- * no more than bufsize number of bytes, including terminating NUL, to buffer.
- * Returns length of string (not including terminating NUL), or -1 if the string was
- * truncated in the buffer due to not having reached the terminating NUL.
- * In this way, it acts like snprintf().
- *
- * When processing a packet where the remaining number of bytes is less
- * than bufsize, an exception is not thrown if the end of the packet
- * is reached before the NUL is found. If no NUL is found before reaching
- * the end of the short packet, -1 is still returned, and the string
- * is truncated with a NUL, albeit not at buffer[bufsize - 1], but
- * at the correct spot, terminating the string.
- */
-gint
-tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8 *buffer)
-{
- gint bytes_copied;
-
- DISSECTOR_ASSERT(tvb && tvb->initialized);
-
- return _tvb_get_nstringz(tvb, offset, bufsize, buffer, &bytes_copied);
-}
-
-/* Like tvb_get_nstringz(), but never returns -1. The string is guaranteed to
- * have a terminating NUL. If the string was truncated when copied into buffer,
- * a NUL is placed at the end of buffer to terminate it.
- */
gint
-tvb_get_nstringz0(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer)
+tvb_get_raw_bytes_as_stringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer)
{
gint len, bytes_copied;
DISSECTOR_ASSERT(tvb && tvb->initialized);
- len = _tvb_get_nstringz(tvb, offset, bufsize, buffer, &bytes_copied);
+ len = _tvb_get_raw_bytes_as_stringz(tvb, offset, bufsize, buffer, &bytes_copied);
if (len == -1) {
buffer[bufsize - 1] = 0;