wmem: Remove strbuf max size parameter
This parameter was introduced as a safeguard for bugs that generate an unbounded string but its utility for that purpose is doubtful and the way it is being used creates problems with invalid truncation of UTF-8 strings. Rename wmem_strbuf_sized_new() with a better name.
This commit is contained in:
parent
3311b34106
commit
32f88ad22c
|
@ -73,7 +73,7 @@ get_ascii_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
|
||||||
{
|
{
|
||||||
wmem_strbuf_t *str;
|
wmem_strbuf_t *str;
|
||||||
|
|
||||||
str = wmem_strbuf_sized_new(scope, length+1, 0);
|
str = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
guint8 ch = *ptr;
|
guint8 ch = *ptr;
|
||||||
|
@ -111,7 +111,7 @@ get_utf_8_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
|
||||||
guint8 ch;
|
guint8 ch;
|
||||||
const guint8 *prev;
|
const guint8 *prev;
|
||||||
|
|
||||||
str = wmem_strbuf_sized_new(scope, length+1, 0);
|
str = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
/* See the Unicode Standard conformance chapter at
|
/* See the Unicode Standard conformance chapter at
|
||||||
* https://www.unicode.org/versions/Unicode13.0.0/ch03.pdf especially
|
* https://www.unicode.org/versions/Unicode13.0.0/ch03.pdf especially
|
||||||
|
@ -253,7 +253,7 @@ get_iso_646_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, cons
|
||||||
{
|
{
|
||||||
wmem_strbuf_t *str;
|
wmem_strbuf_t *str;
|
||||||
|
|
||||||
str = wmem_strbuf_sized_new(scope, length+1, 0);
|
str = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
guint8 ch = *ptr;
|
guint8 ch = *ptr;
|
||||||
|
@ -279,7 +279,7 @@ get_8859_1_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
|
||||||
{
|
{
|
||||||
wmem_strbuf_t *str;
|
wmem_strbuf_t *str;
|
||||||
|
|
||||||
str = wmem_strbuf_sized_new(scope, length+1, 0);
|
str = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
guint8 ch = *ptr;
|
guint8 ch = *ptr;
|
||||||
|
@ -779,7 +779,7 @@ get_unichar2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, con
|
||||||
{
|
{
|
||||||
wmem_strbuf_t *str;
|
wmem_strbuf_t *str;
|
||||||
|
|
||||||
str = wmem_strbuf_sized_new(scope, length+1, 0);
|
str = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
guint8 ch = *ptr;
|
guint8 ch = *ptr;
|
||||||
|
@ -813,7 +813,7 @@ get_ucs_2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const
|
||||||
gint i; /* Byte counter for string */
|
gint i; /* Byte counter for string */
|
||||||
wmem_strbuf_t *strbuf;
|
wmem_strbuf_t *strbuf;
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
|
strbuf = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
for(i = 0; i + 1 < length; i += 2) {
|
for(i = 0; i + 1 < length; i += 2) {
|
||||||
if (encoding == ENC_BIG_ENDIAN){
|
if (encoding == ENC_BIG_ENDIAN){
|
||||||
|
@ -853,7 +853,7 @@ get_utf_16_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const
|
||||||
gunichar uchar;
|
gunichar uchar;
|
||||||
gint i; /* Byte counter for string */
|
gint i; /* Byte counter for string */
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
|
strbuf = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
for(i = 0; i + 1 < length; i += 2) {
|
for(i = 0; i + 1 < length; i += 2) {
|
||||||
if (encoding == ENC_BIG_ENDIAN)
|
if (encoding == ENC_BIG_ENDIAN)
|
||||||
|
@ -940,7 +940,7 @@ get_ucs_4_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const
|
||||||
gint i; /* Byte counter for string */
|
gint i; /* Byte counter for string */
|
||||||
wmem_strbuf_t *strbuf;
|
wmem_strbuf_t *strbuf;
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
|
strbuf = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
for(i = 0; i + 3 < length; i += 4) {
|
for(i = 0; i + 3 < length; i += 4) {
|
||||||
if (encoding == ENC_BIG_ENDIAN)
|
if (encoding == ENC_BIG_ENDIAN)
|
||||||
|
@ -1073,7 +1073,7 @@ get_ts_23_038_7bits_string_packed(wmem_allocator_t *scope, const guint8 *ptr,
|
||||||
gboolean saw_escape = FALSE;
|
gboolean saw_escape = FALSE;
|
||||||
int bits;
|
int bits;
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(scope, no_of_chars+1, 0);
|
strbuf = wmem_strbuf_new_sized(scope, no_of_chars+1);
|
||||||
|
|
||||||
bits = bit_offset & 0x07;
|
bits = bit_offset & 0x07;
|
||||||
if (!bits) {
|
if (!bits) {
|
||||||
|
@ -1142,7 +1142,7 @@ get_ts_23_038_7bits_string_unpacked(wmem_allocator_t *scope, const guint8 *ptr,
|
||||||
gint i; /* Byte counter for string */
|
gint i; /* Byte counter for string */
|
||||||
gboolean saw_escape = FALSE;
|
gboolean saw_escape = FALSE;
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
|
strbuf = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
saw_escape = handle_ts_23_038_char(strbuf, *ptr++, saw_escape);
|
saw_escape = handle_ts_23_038_char(strbuf, *ptr++, saw_escape);
|
||||||
|
@ -1218,7 +1218,7 @@ get_etsi_ts_102_221_annex_a_string(wmem_allocator_t *scope, const guint8 *ptr,
|
||||||
ptr++;
|
ptr++;
|
||||||
length--;
|
length--;
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(scope, 2*string_len+1, 0);
|
strbuf = wmem_strbuf_new_sized(scope, 2*string_len+1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the UCS-2 base.
|
* Get the UCS-2 base.
|
||||||
|
@ -1295,7 +1295,7 @@ get_ascii_7bits_string(wmem_allocator_t *scope, const guint8 *ptr,
|
||||||
bits = 7;
|
bits = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(scope, no_of_chars+1, 0);
|
strbuf = wmem_strbuf_new_sized(scope, no_of_chars+1);
|
||||||
for(char_count = 0; char_count < no_of_chars; ptr++) {
|
for(char_count = 0; char_count < no_of_chars; ptr++) {
|
||||||
/* Get the next byte from the string. */
|
/* Get the next byte from the string. */
|
||||||
in_byte = *ptr;
|
in_byte = *ptr;
|
||||||
|
@ -1428,7 +1428,7 @@ get_nonascii_unichar2_string(wmem_allocator_t *scope, const guint8 *ptr, gint le
|
||||||
{
|
{
|
||||||
wmem_strbuf_t *str;
|
wmem_strbuf_t *str;
|
||||||
|
|
||||||
str = wmem_strbuf_sized_new(scope, length+1, 0);
|
str = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0) {
|
||||||
guint8 ch = *ptr;
|
guint8 ch = *ptr;
|
||||||
|
@ -1471,7 +1471,7 @@ get_string_enc_iconv(wmem_allocator_t *scope, const guint8 *ptr, gint length, co
|
||||||
}
|
}
|
||||||
|
|
||||||
inbytes = length;
|
inbytes = length;
|
||||||
str = wmem_strbuf_sized_new(scope, length+1, 0);
|
str = wmem_strbuf_new_sized(scope, length+1);
|
||||||
/* XXX: If speed becomes an issue, the faster way to do this would
|
/* XXX: If speed becomes an issue, the faster way to do this would
|
||||||
* involve passing the wmem_strbuf_t's string buffer directly into
|
* involve passing the wmem_strbuf_t's string buffer directly into
|
||||||
* g_iconv to avoid a memcpy later, but that requires changes to the
|
* g_iconv to avoid a memcpy later, but that requires changes to the
|
||||||
|
@ -1846,7 +1846,7 @@ get_t61_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
|
||||||
const guint8 *c;
|
const guint8 *c;
|
||||||
wmem_strbuf_t *strbuf;
|
wmem_strbuf_t *strbuf;
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
|
strbuf = wmem_strbuf_new_sized(scope, length+1);
|
||||||
|
|
||||||
for (i = 0, c = ptr; i < length; c++, i++) {
|
for (i = 0, c = ptr; i < length; c++, i++) {
|
||||||
if (!t61_tab[*c]) {
|
if (!t61_tab[*c]) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ string_walk(GSList *args, guint32 arg_count, GSList **retval, gchar(*conv_func)(
|
||||||
/* XXX - it would be nice to handle FT_TVBUFF, too */
|
/* XXX - it would be nice to handle FT_TVBUFF, too */
|
||||||
if (IS_FT_STRING(fvalue_type_ftenum(arg_fvalue))) {
|
if (IS_FT_STRING(fvalue_type_ftenum(arg_fvalue))) {
|
||||||
src = fvalue_get_strbuf(arg_fvalue);
|
src = fvalue_get_strbuf(arg_fvalue);
|
||||||
dst = wmem_strbuf_sized_new(NULL, src->len, 0);
|
dst = wmem_strbuf_new_sized(NULL, src->len);
|
||||||
for (size_t i = 0; i < src->len; i++) {
|
for (size_t i = 0; i < src->len; i++) {
|
||||||
wmem_strbuf_append_c(dst, conv_func(src->str[i]));
|
wmem_strbuf_append_c(dst, conv_func(src->str[i]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -828,7 +828,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
|
||||||
|
|
||||||
/* Reset the digits string in the private data struct */
|
/* Reset the digits string in the private data struct */
|
||||||
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
|
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
|
||||||
mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
|
mcc_mnc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
|
||||||
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
|
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
|
||||||
/* Reset parsing failure flag*/
|
/* Reset parsing failure flag*/
|
||||||
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
||||||
|
@ -846,7 +846,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
|
||||||
if(string_len >= 3)
|
if(string_len >= 3)
|
||||||
{
|
{
|
||||||
/* 3 MCC digits were found, keep for later in case MCC is missing in other PLMN ids*/
|
/* 3 MCC digits were found, keep for later in case MCC is missing in other PLMN ids*/
|
||||||
mcc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,4,4);
|
mcc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,4);
|
||||||
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[0]);
|
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[0]);
|
||||||
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[1]);
|
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[1]);
|
||||||
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[2]);
|
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[2]);
|
||||||
|
@ -871,7 +871,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
|
||||||
|
|
||||||
/* Reset the digits string in the private data struct */
|
/* Reset the digits string in the private data struct */
|
||||||
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
|
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
|
||||||
mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
|
mcc_mnc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
|
||||||
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
|
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
|
||||||
/* Reset parsing failure flag*/
|
/* Reset parsing failure flag*/
|
||||||
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
||||||
|
@ -888,7 +888,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
|
||||||
if (string_len > 3) {
|
if (string_len > 3) {
|
||||||
/* 3 MCC digits and at least 1 MNC digit were found, keep MCC for later
|
/* 3 MCC digits and at least 1 MNC digit were found, keep MCC for later
|
||||||
in case it's missing in other PLMN ids*/
|
in case it's missing in other PLMN ids*/
|
||||||
temp_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,4,4);
|
temp_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,4);
|
||||||
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[0]);
|
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[0]);
|
||||||
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[1]);
|
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[1]);
|
||||||
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[2]);
|
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[2]);
|
||||||
|
@ -902,7 +902,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
|
||||||
if(last_mcc_strbuf)
|
if(last_mcc_strbuf)
|
||||||
{
|
{
|
||||||
/* Concat MCC and MNC in temp buffer */
|
/* Concat MCC and MNC in temp buffer */
|
||||||
temp_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
|
temp_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
|
||||||
wmem_strbuf_append_printf(temp_strbuf,"%%s",wmem_strbuf_get_str(last_mcc_strbuf));
|
wmem_strbuf_append_printf(temp_strbuf,"%%s",wmem_strbuf_get_str(last_mcc_strbuf));
|
||||||
wmem_strbuf_append_printf(temp_strbuf,"%%s",mcc_mnc_string);
|
wmem_strbuf_append_printf(temp_strbuf,"%%s",mcc_mnc_string);
|
||||||
/* Update length of recovered MCC-MNC pair */
|
/* Update length of recovered MCC-MNC pair */
|
||||||
|
@ -929,7 +929,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
|
||||||
tvbuff_t* imsi_tvb;
|
tvbuff_t* imsi_tvb;
|
||||||
|
|
||||||
/* Reset the digits string in the private data struct */
|
/* Reset the digits string in the private data struct */
|
||||||
imsi_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,16,16);
|
imsi_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,16);
|
||||||
private_data_set_digits_strbuf(actx, imsi_strbuf);
|
private_data_set_digits_strbuf(actx, imsi_strbuf);
|
||||||
/* Reset parsing failure flag*/
|
/* Reset parsing failure flag*/
|
||||||
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
||||||
|
|
|
@ -341,7 +341,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.188" "id-at-primaryMember"
|
||||||
/* now append this to the DN */
|
/* now append this to the DN */
|
||||||
if (last_dn_buf) {
|
if (last_dn_buf) {
|
||||||
if(wmem_strbuf_get_len(last_dn_buf) > 0) {
|
if(wmem_strbuf_get_len(last_dn_buf) > 0) {
|
||||||
wmem_strbuf_t *temp_dn_buf = wmem_strbuf_sized_new(actx->pinfo->pool, wmem_strbuf_get_len(last_rdn_buf) + wmem_strbuf_get_len(last_dn_buf) + 1, 0);
|
wmem_strbuf_t *temp_dn_buf = wmem_strbuf_new_sized(actx->pinfo->pool, wmem_strbuf_get_len(last_rdn_buf) + wmem_strbuf_get_len(last_dn_buf) + 1);
|
||||||
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_rdn_buf));
|
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_rdn_buf));
|
||||||
wmem_strbuf_append_c(temp_dn_buf, ',');
|
wmem_strbuf_append_c(temp_dn_buf, ',');
|
||||||
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_dn_buf));
|
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_dn_buf));
|
||||||
|
|
|
@ -304,10 +304,6 @@ enum _9p_qid_t {
|
||||||
#define _9P_NONUNAME (guint32)(~0)
|
#define _9P_NONUNAME (guint32)(~0)
|
||||||
#define _9P_MAXWELEM 16
|
#define _9P_MAXWELEM 16
|
||||||
|
|
||||||
#ifndef MAXPATHLEN
|
|
||||||
#define MAXPATHLEN 1024
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Length prefixed string type
|
* @brief Length prefixed string type
|
||||||
|
@ -1337,7 +1333,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
|
||||||
fid_path = conv_get_fid(pinfo, fid);
|
fid_path = conv_get_fid(pinfo, fid);
|
||||||
proto_item_append_text(ti, " (%s)", fid_path);
|
proto_item_append_text(ti, " (%s)", fid_path);
|
||||||
if (!pinfo->fd->visited) {
|
if (!pinfo->fd->visited) {
|
||||||
tmppath = wmem_strbuf_sized_new(pinfo->pool, 0, MAXPATHLEN);
|
tmppath = wmem_strbuf_create(pinfo->pool);
|
||||||
wmem_strbuf_append(tmppath, fid_path);
|
wmem_strbuf_append(tmppath, fid_path);
|
||||||
}
|
}
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
@ -1430,7 +1426,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
|
||||||
|
|
||||||
if (!pinfo->fd->visited) {
|
if (!pinfo->fd->visited) {
|
||||||
_9p_len = tvb_get_letohs(tvb, offset);
|
_9p_len = tvb_get_letohs(tvb, offset);
|
||||||
tmppath = wmem_strbuf_sized_new(pinfo->pool, 0, MAXPATHLEN);
|
tmppath = wmem_strbuf_create(pinfo->pool);
|
||||||
wmem_strbuf_append(tmppath, fid_path);
|
wmem_strbuf_append(tmppath, fid_path);
|
||||||
wmem_strbuf_append_c(tmppath, '/');
|
wmem_strbuf_append_c(tmppath, '/');
|
||||||
tvb_s = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset+2, _9p_len, ENC_UTF_8|ENC_NA);
|
tvb_s = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset+2, _9p_len, ENC_UTF_8|ENC_NA);
|
||||||
|
@ -1463,7 +1459,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
|
||||||
|
|
||||||
if (!pinfo->fd->visited) {
|
if (!pinfo->fd->visited) {
|
||||||
_9p_len = tvb_get_letohs(tvb, offset);
|
_9p_len = tvb_get_letohs(tvb, offset);
|
||||||
tmppath = wmem_strbuf_sized_new(pinfo->pool, 0, MAXPATHLEN);
|
tmppath = wmem_strbuf_create(pinfo->pool);
|
||||||
wmem_strbuf_append(tmppath, fid_path);
|
wmem_strbuf_append(tmppath, fid_path);
|
||||||
wmem_strbuf_append_c(tmppath, '/');
|
wmem_strbuf_append_c(tmppath, '/');
|
||||||
tvb_s = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset+2, _9p_len, ENC_UTF_8|ENC_NA);
|
tvb_s = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset+2, _9p_len, ENC_UTF_8|ENC_NA);
|
||||||
|
@ -1808,7 +1804,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
|
||||||
|
|
||||||
if (!pinfo->fd->visited) {
|
if (!pinfo->fd->visited) {
|
||||||
_9p_len = tvb_get_letohs(tvb, offset);
|
_9p_len = tvb_get_letohs(tvb, offset);
|
||||||
tmppath = wmem_strbuf_sized_new(pinfo->pool, 0, MAXPATHLEN);
|
tmppath = wmem_strbuf_create(pinfo->pool);
|
||||||
wmem_strbuf_append(tmppath, conv_get_fid(pinfo, dfid));
|
wmem_strbuf_append(tmppath, conv_get_fid(pinfo, dfid));
|
||||||
wmem_strbuf_append_c(tmppath, '/');
|
wmem_strbuf_append_c(tmppath, '/');
|
||||||
|
|
||||||
|
|
|
@ -545,7 +545,7 @@ static void OUT_RXString(ptvcursor_t *cursor, int field)
|
||||||
static void OUT_RXStringV(ptvcursor_t *cursor, int field, guint32 length)
|
static void OUT_RXStringV(ptvcursor_t *cursor, int field, guint32 length)
|
||||||
{
|
{
|
||||||
tvbuff_t* tvb = ptvcursor_tvbuff(cursor);
|
tvbuff_t* tvb = ptvcursor_tvbuff(cursor);
|
||||||
wmem_strbuf_t *strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), length+1, 0);
|
wmem_strbuf_t *strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), length+1);
|
||||||
int offset = ptvcursor_current_offset(cursor),
|
int offset = ptvcursor_current_offset(cursor),
|
||||||
start_offset = offset;
|
start_offset = offset;
|
||||||
guint32 idx;
|
guint32 idx;
|
||||||
|
|
|
@ -730,7 +730,7 @@ awdl_tag_channel_sequence(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
/* make sufficient space for channel decodings: 5 chars/channel (3-digit number + ', ') */
|
/* make sufficient space for channel decodings: 5 chars/channel (3-digit number + ', ') */
|
||||||
strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), 5 * channels, 5 * channels);
|
strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), 5 * channels);
|
||||||
|
|
||||||
switch (seq_enc) {
|
switch (seq_enc) {
|
||||||
case AWDL_CHANSEQ_ENC_CHANNELNUMBER:
|
case AWDL_CHANSEQ_ENC_CHANNELNUMBER:
|
||||||
|
@ -1139,7 +1139,7 @@ add_awdl_dns_name(proto_tree *tree, int hfindex_regular, int hfindex_compressed,
|
||||||
const guchar *component;
|
const guchar *component;
|
||||||
wmem_strbuf_t *strbuf;
|
wmem_strbuf_t *strbuf;
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), MAX_DNAME_LEN, MAX_DNAME_LEN);
|
strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), MAX_DNAME_LEN);
|
||||||
|
|
||||||
while (offset < (len + start_offset)) {
|
while (offset < (len + start_offset)) {
|
||||||
component_len = tvb_get_guint8(tvb, offset);
|
component_len = tvb_get_guint8(tvb, offset);
|
||||||
|
|
|
@ -564,7 +564,7 @@ static void dissect_cimd_ud(tvbuff_t *tvb, proto_tree *tree, gint pindex, gint s
|
||||||
g_size = endOffset - g_offset;
|
g_size = endOffset - g_offset;
|
||||||
|
|
||||||
payloadText = tvb_get_ptr(tvb, g_offset, g_size);
|
payloadText = tvb_get_ptr(tvb, g_offset, g_size);
|
||||||
tmpBuffer = wmem_strbuf_sized_new(wmem_packet_scope(), g_size+1, 0);
|
tmpBuffer = wmem_strbuf_new_sized(wmem_packet_scope(), g_size+1);
|
||||||
for (loop = 0; loop < g_size; loop++)
|
for (loop = 0; loop < g_size; loop++)
|
||||||
{
|
{
|
||||||
if (payloadText[loop] == '_')
|
if (payloadText[loop] == '_')
|
||||||
|
|
|
@ -1323,8 +1323,8 @@ dissect_coap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
|
||||||
coinfo->block_option = 0;
|
coinfo->block_option = 0;
|
||||||
coinfo->block_number = DEFAULT_COAP_BLOCK_NUMBER;
|
coinfo->block_number = DEFAULT_COAP_BLOCK_NUMBER;
|
||||||
coinfo->block_mflag = 0;
|
coinfo->block_mflag = 0;
|
||||||
coinfo->uri_str_strbuf = wmem_strbuf_sized_new(pinfo->pool, 0, 1024);
|
coinfo->uri_str_strbuf = wmem_strbuf_create(pinfo->pool);
|
||||||
coinfo->uri_query_strbuf = wmem_strbuf_sized_new(pinfo->pool, 0, 1024);
|
coinfo->uri_query_strbuf = wmem_strbuf_create(pinfo->pool);
|
||||||
/* Allocate pointers and static elements of oscore_info_t, arrays are allocated only if object security option is found during option parsing */
|
/* Allocate pointers and static elements of oscore_info_t, arrays are allocated only if object security option is found during option parsing */
|
||||||
coinfo->oscore_info = wmem_new0(pinfo->pool, oscore_info_t);
|
coinfo->oscore_info = wmem_new0(pinfo->pool, oscore_info_t);
|
||||||
coinfo->object_security = FALSE;
|
coinfo->object_security = FALSE;
|
||||||
|
|
|
@ -397,7 +397,7 @@ static gint dissect_etf_big_ext(tvbuff_t *tvb, gint offset, guint32 len, proto_t
|
||||||
*value_str = wmem_strdup_printf(wmem_packet_scope(), "%s%" PRIu64,
|
*value_str = wmem_strdup_printf(wmem_packet_scope(), "%s%" PRIu64,
|
||||||
sign ? "-" : "", big_val);
|
sign ? "-" : "", big_val);
|
||||||
} if (len < 64) {
|
} if (len < 64) {
|
||||||
wmem_strbuf_t *strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), len*1+3+1, len*1+3+1);
|
wmem_strbuf_t *strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), len*1+3+1);
|
||||||
|
|
||||||
wmem_strbuf_append(strbuf, "0x");
|
wmem_strbuf_append(strbuf, "0x");
|
||||||
for (i = len - 1; i >= 0; i--) {
|
for (i = len - 1; i >= 0; i--) {
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
||||||
ENDTRY;
|
ENDTRY;
|
||||||
|
|
||||||
if (proto_field_is_referenced(tree, hf_frame_protocols)) {
|
if (proto_field_is_referenced(tree, hf_frame_protocols)) {
|
||||||
wmem_strbuf_t *val = wmem_strbuf_sized_new(pinfo->pool, 128, 0);
|
wmem_strbuf_t *val = wmem_strbuf_new_sized(pinfo->pool, 128);
|
||||||
wmem_list_frame_t *frame;
|
wmem_list_frame_t *frame;
|
||||||
/* skip the first entry, it's always the "frame" protocol */
|
/* skip the first entry, it's always the "frame" protocol */
|
||||||
frame = wmem_list_frame_next(wmem_list_head(pinfo->layers));
|
frame = wmem_list_frame_next(wmem_list_head(pinfo->layers));
|
||||||
|
|
|
@ -11704,7 +11704,7 @@ dtap_rr_ec_paging_imsi(tvbuff_t *tvb, proto_tree *tree, guint32 curr_bit_offset)
|
||||||
proto_tree_add_bits_ret_val(tree, hf_gsm_a_rr_ec_imsi_digits, tvb, curr_bit_offset, 4, &imsi_digits, ENC_BIG_ENDIAN);
|
proto_tree_add_bits_ret_val(tree, hf_gsm_a_rr_ec_imsi_digits, tvb, curr_bit_offset, 4, &imsi_digits, ENC_BIG_ENDIAN);
|
||||||
curr_bit_offset += 4;
|
curr_bit_offset += 4;
|
||||||
sav_bit_offset = curr_bit_offset;
|
sav_bit_offset = curr_bit_offset;
|
||||||
imsi_str = wmem_strbuf_sized_new(wmem_packet_scope(), (gsize)imsi_digits+2, 0);
|
imsi_str = wmem_strbuf_new_sized(wmem_packet_scope(), (gsize)imsi_digits+2);
|
||||||
for (i = 0; i <= (guint8)imsi_digits; i++) {
|
for (i = 0; i <= (guint8)imsi_digits; i++) {
|
||||||
wmem_strbuf_append_c(imsi_str, digits[tvb_get_bits8(tvb, curr_bit_offset, 4)]);
|
wmem_strbuf_append_c(imsi_str, digits[tvb_get_bits8(tvb, curr_bit_offset, 4)]);
|
||||||
curr_bit_offset += 4;
|
curr_bit_offset += 4;
|
||||||
|
|
|
@ -3440,7 +3440,7 @@ dissect_isup_digits_common(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
|
strbuf_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
|
||||||
|
|
||||||
/* Make the digit string, looping on captured length (in case a snaplen was set) */
|
/* Make the digit string, looping on captured length (in case a snaplen was set) */
|
||||||
captured_length = tvb_captured_length_remaining(tvb, offset);
|
captured_length = tvb_captured_length_remaining(tvb, offset);
|
||||||
|
@ -7151,7 +7151,7 @@ dissect_japan_isup_network_poi_cad(tvbuff_t *parameter_tvb, packet_info *pinfo,
|
||||||
guint8 carrier_info_length;
|
guint8 carrier_info_length;
|
||||||
gint num_octets_with_digits = 0;
|
gint num_octets_with_digits = 0;
|
||||||
gint digit_index = 0;
|
gint digit_index = 0;
|
||||||
wmem_strbuf_t *ca_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
|
wmem_strbuf_t *ca_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
|
||||||
|
|
||||||
/* POI Hierarchy information
|
/* POI Hierarchy information
|
||||||
|
|
||||||
|
@ -7518,7 +7518,7 @@ dissect_japan_isup_carrier_information(tvbuff_t *parameter_tvb, packet_info *pin
|
||||||
/* Lets now load up the digits.*/
|
/* Lets now load up the digits.*/
|
||||||
/* If the odd indicator is set... drop the Filler from the last octet.*/
|
/* If the odd indicator is set... drop the Filler from the last octet.*/
|
||||||
/* This loop also loads up ca_number with the digits for display*/
|
/* This loop also loads up ca_number with the digits for display*/
|
||||||
ca_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
|
ca_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
|
||||||
digit_index = 0;
|
digit_index = 0;
|
||||||
while (num_octets_with_digits > 0) {
|
while (num_octets_with_digits > 0) {
|
||||||
offset += 1;
|
offset += 1;
|
||||||
|
@ -7588,7 +7588,7 @@ dissect_japan_isup_carrier_information(tvbuff_t *parameter_tvb, packet_info *pin
|
||||||
/* Lets now load up the digits.*/
|
/* Lets now load up the digits.*/
|
||||||
/* If the odd indicator is set... drop the Filler from the last octet.*/
|
/* If the odd indicator is set... drop the Filler from the last octet.*/
|
||||||
/* This loop also loads up cid_number with the digits for display*/
|
/* This loop also loads up cid_number with the digits for display*/
|
||||||
cid_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
|
cid_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
|
||||||
digit_index = 0;
|
digit_index = 0;
|
||||||
while (num_octets_with_digits > 0) {
|
while (num_octets_with_digits > 0) {
|
||||||
offset += 1;
|
offset += 1;
|
||||||
|
@ -7718,7 +7718,7 @@ dissect_japan_isup_charge_area_info(tvbuff_t *parameter_tvb, packet_info *pinfo,
|
||||||
gint odd_even;
|
gint odd_even;
|
||||||
gint digit_index = 0;
|
gint digit_index = 0;
|
||||||
|
|
||||||
wmem_strbuf_t *ca_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
|
wmem_strbuf_t *ca_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
|
||||||
|
|
||||||
/*Octet 1 : Indicator*/
|
/*Octet 1 : Indicator*/
|
||||||
octet = tvb_get_guint8(parameter_tvb, 0);
|
octet = tvb_get_guint8(parameter_tvb, 0);
|
||||||
|
|
|
@ -143,7 +143,7 @@ json_string_unescape(wmem_allocator_t *scope, const char *string, size_t *length
|
||||||
size_t read_index = 0;
|
size_t read_index = 0;
|
||||||
size_t string_length = strlen(string);
|
size_t string_length = strlen(string);
|
||||||
|
|
||||||
wmem_strbuf_t* output_string_buffer = wmem_strbuf_sized_new(scope, string_length, 0);
|
wmem_strbuf_t* output_string_buffer = wmem_strbuf_new_sized(scope, string_length);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,8 +118,7 @@ dissect_nwp_ann(tvbuff_t *tvb, proto_tree *nwp_tree, guint8 hid_count,
|
||||||
NWPH_HWAD + ha_len, hid_count * NWP_XID_LEN, ENC_NA);
|
NWPH_HWAD + ha_len, hid_count * NWP_XID_LEN, ENC_NA);
|
||||||
hid_tree = proto_item_add_subtree(ti, ett_nwp_ann_hid_tree);
|
hid_tree = proto_item_add_subtree(ti, ett_nwp_ann_hid_tree);
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(wmem_packet_scope(),
|
buf = wmem_strbuf_new_sized(wmem_packet_scope(), NWP_HID_STR_LEN);
|
||||||
NWP_HID_STR_LEN, NWP_HID_STR_LEN);
|
|
||||||
|
|
||||||
/* Add HIDs. */
|
/* Add HIDs. */
|
||||||
offset = NWPH_HWAD + ha_len;
|
offset = NWPH_HWAD + ha_len;
|
||||||
|
@ -157,8 +156,8 @@ dissect_nwp_nl(tvbuff_t *tvb, proto_tree *nwp_tree, guint8 hid_count,
|
||||||
guint i;
|
guint i;
|
||||||
guint8 offset = NWPH_NLST;
|
guint8 offset = NWPH_NLST;
|
||||||
|
|
||||||
wmem_strbuf_t *hid_buf = wmem_strbuf_sized_new(wmem_packet_scope(),
|
wmem_strbuf_t *hid_buf = wmem_strbuf_new_sized(wmem_packet_scope(),
|
||||||
NWP_HID_STR_LEN, NWP_HID_STR_LEN);
|
NWP_HID_STR_LEN);
|
||||||
|
|
||||||
/* Set up tree for neighbor list. */
|
/* Set up tree for neighbor list. */
|
||||||
pi = proto_tree_add_item(nwp_tree, hf_nwp_neigh_list,
|
pi = proto_tree_add_item(nwp_tree, hf_nwp_neigh_list,
|
||||||
|
|
|
@ -2525,7 +2525,7 @@ static const fragment_items opa_rmpp_frag_items = {
|
||||||
* @param[out] num_ports optional: pointer to a number of ports in set in port
|
* @param[out] num_ports optional: pointer to a number of ports in set in port
|
||||||
* select mask and portlist if provided.
|
* select mask and portlist if provided.
|
||||||
* @return gchar* pointer to range string allocated using
|
* @return gchar* pointer to range string allocated using
|
||||||
* wmem_strbuf_sized_new(wmem_packet_scope(),...)
|
* wmem_strbuf_new_sized(wmem_packet_scope(),...)
|
||||||
*/
|
*/
|
||||||
static gchar *opa_format_port_select_mask(tvbuff_t *tvb, gint offset, guint8 **port_list, guint8 *num_ports)
|
static gchar *opa_format_port_select_mask(tvbuff_t *tvb, gint offset, guint8 **port_list, guint8 *num_ports)
|
||||||
{
|
{
|
||||||
|
@ -2542,7 +2542,7 @@ static gchar *opa_format_port_select_mask(tvbuff_t *tvb, gint offset, guint8 **p
|
||||||
psm[2] = tvb_get_ntoh64(tvb, offset + 16);
|
psm[2] = tvb_get_ntoh64(tvb, offset + 16);
|
||||||
psm[3] = tvb_get_ntoh64(tvb, offset + 24);
|
psm[3] = tvb_get_ntoh64(tvb, offset + 24);
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(wmem_packet_scope(), 0, ITEM_LABEL_LENGTH);
|
buf = wmem_strbuf_create(wmem_packet_scope());
|
||||||
|
|
||||||
if (port_list) {
|
if (port_list) {
|
||||||
/* Allocate list of ports; max = 256 = 64 * 4 */
|
/* Allocate list of ports; max = 256 = 64 * 4 */
|
||||||
|
|
|
@ -1700,7 +1700,7 @@ buffer_error(const gchar *fmt, ...)
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
if (err_msg_buf == NULL)
|
if (err_msg_buf == NULL)
|
||||||
err_msg_buf = wmem_strbuf_sized_new(wmem_epan_scope(), MIN_ERR_STR_BUF_SIZE, MAX_ERR_STR_BUF_SIZE);
|
err_msg_buf = wmem_strbuf_new_sized(wmem_epan_scope(), MIN_ERR_STR_BUF_SIZE);
|
||||||
|
|
||||||
wmem_strbuf_append_vprintf(err_msg_buf, fmt, ap);
|
wmem_strbuf_append_vprintf(err_msg_buf, fmt, ap);
|
||||||
|
|
||||||
|
|
|
@ -680,7 +680,7 @@ dissect_ascend_data_filter(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _
|
||||||
return wmem_strdup_printf(wmem_packet_scope(), "Wrong attribute length %d", len);
|
return wmem_strdup_printf(wmem_packet_scope(), "Wrong attribute length %d", len);
|
||||||
}
|
}
|
||||||
|
|
||||||
filterstr = wmem_strbuf_sized_new(wmem_packet_scope(), 128, 128);
|
filterstr = wmem_strbuf_new_sized(wmem_packet_scope(), 128);
|
||||||
|
|
||||||
ti = proto_tree_add_item(tree, hf_radius_ascend_data_filter, tvb, 0, -1, ENC_NA);
|
ti = proto_tree_add_item(tree, hf_radius_ascend_data_filter, tvb, 0, -1, ENC_NA);
|
||||||
ascend_tree = proto_item_add_subtree(ti, ett_radius_ascend);
|
ascend_tree = proto_item_add_subtree(ti, ett_radius_ascend);
|
||||||
|
|
|
@ -19010,7 +19010,7 @@ dissect_rrc_PLMN_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U
|
||||||
|
|
||||||
/* Reset the digits string in the private data struct */
|
/* Reset the digits string in the private data struct */
|
||||||
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
|
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
|
||||||
mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
|
mcc_mnc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
|
||||||
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
|
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
|
||||||
/* Reset parsing failure flag*/
|
/* Reset parsing failure flag*/
|
||||||
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
||||||
|
@ -19030,7 +19030,7 @@ dissect_rrc_PLMN_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U
|
||||||
if(string_len >= 3)
|
if(string_len >= 3)
|
||||||
{
|
{
|
||||||
/* 3 MCC digits were found, keep for later in case MCC is missing in other PLMN ids*/
|
/* 3 MCC digits were found, keep for later in case MCC is missing in other PLMN ids*/
|
||||||
mcc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,4,4);
|
mcc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,4);
|
||||||
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[0]);
|
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[0]);
|
||||||
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[1]);
|
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[1]);
|
||||||
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[2]);
|
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[2]);
|
||||||
|
@ -116016,7 +116016,7 @@ dissect_rrc_IMSI_GSM_MAP(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_
|
||||||
tvbuff_t* imsi_tvb;
|
tvbuff_t* imsi_tvb;
|
||||||
|
|
||||||
/* Reset the digits string in the private data struct */
|
/* Reset the digits string in the private data struct */
|
||||||
imsi_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,16,16);
|
imsi_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,16);
|
||||||
private_data_set_digits_strbuf(actx, imsi_strbuf);
|
private_data_set_digits_strbuf(actx, imsi_strbuf);
|
||||||
/* Reset parsing failure flag*/
|
/* Reset parsing failure flag*/
|
||||||
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
||||||
|
@ -135772,7 +135772,7 @@ dissect_rrc_PLMN_IdentityWithOptionalMCC_r6(tvbuff_t *tvb _U_, int offset _U_, a
|
||||||
|
|
||||||
/* Reset the digits string in the private data struct */
|
/* Reset the digits string in the private data struct */
|
||||||
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
|
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
|
||||||
mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
|
mcc_mnc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
|
||||||
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
|
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
|
||||||
/* Reset parsing failure flag*/
|
/* Reset parsing failure flag*/
|
||||||
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
|
||||||
|
@ -135791,7 +135791,7 @@ dissect_rrc_PLMN_IdentityWithOptionalMCC_r6(tvbuff_t *tvb _U_, int offset _U_, a
|
||||||
if (string_len > 3) {
|
if (string_len > 3) {
|
||||||
/* 3 MCC digits and at least 1 MNC digit were found, keep MCC for later
|
/* 3 MCC digits and at least 1 MNC digit were found, keep MCC for later
|
||||||
in case it's missing in other PLMN ids*/
|
in case it's missing in other PLMN ids*/
|
||||||
temp_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,4,4);
|
temp_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,4);
|
||||||
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[0]);
|
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[0]);
|
||||||
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[1]);
|
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[1]);
|
||||||
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[2]);
|
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[2]);
|
||||||
|
@ -135805,7 +135805,7 @@ dissect_rrc_PLMN_IdentityWithOptionalMCC_r6(tvbuff_t *tvb _U_, int offset _U_, a
|
||||||
if(last_mcc_strbuf)
|
if(last_mcc_strbuf)
|
||||||
{
|
{
|
||||||
/* Concat MCC and MNC in temp buffer */
|
/* Concat MCC and MNC in temp buffer */
|
||||||
temp_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
|
temp_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
|
||||||
wmem_strbuf_append_printf(temp_strbuf,"%s",wmem_strbuf_get_str(last_mcc_strbuf));
|
wmem_strbuf_append_printf(temp_strbuf,"%s",wmem_strbuf_get_str(last_mcc_strbuf));
|
||||||
wmem_strbuf_append_printf(temp_strbuf,"%s",mcc_mnc_string);
|
wmem_strbuf_append_printf(temp_strbuf,"%s",mcc_mnc_string);
|
||||||
/* Update length of recovered MCC-MNC pair */
|
/* Update length of recovered MCC-MNC pair */
|
||||||
|
|
|
@ -69,7 +69,7 @@ format_flags_string(guchar value, const gchar *array[])
|
||||||
wmem_strbuf_t *buf;
|
wmem_strbuf_t *buf;
|
||||||
const char *sep = "";
|
const char *sep = "";
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(wmem_packet_scope(), MAX_FLAGS_LEN, MAX_FLAGS_LEN);
|
buf = wmem_strbuf_new_sized(wmem_packet_scope(), MAX_FLAGS_LEN);
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
bpos = 1 << i;
|
bpos = 1 << i;
|
||||||
if (value & bpos) {
|
if (value & bpos) {
|
||||||
|
|
|
@ -2339,7 +2339,7 @@ dissect_skinny_displayLabel(ptvcursor_t *cursor, packet_info *pinfo, int hfindex
|
||||||
|
|
||||||
item = proto_tree_add_item(tree, hfindex, tvb, offset, length, ENC_ASCII);
|
item = proto_tree_add_item(tree, hfindex, tvb, offset, length, ENC_ASCII);
|
||||||
|
|
||||||
wmem_new = wmem_strbuf_sized_new(pinfo->pool, length + 1, 0);
|
wmem_new = wmem_strbuf_new_sized(pinfo->pool, length + 1);
|
||||||
disp_string = (gchar*) wmem_alloc(pinfo->pool, length + 1);
|
disp_string = (gchar*) wmem_alloc(pinfo->pool, length + 1);
|
||||||
disp_string[length] = '\0';
|
disp_string[length] = '\0';
|
||||||
tvb_memcpy(tvb, (void*)disp_string, offset, length);
|
tvb_memcpy(tvb, (void*)disp_string, offset, length);
|
||||||
|
|
|
@ -4539,7 +4539,7 @@ dissect_tds7_login(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tds_conv
|
||||||
wmem_strbuf_t *val2;
|
wmem_strbuf_t *val2;
|
||||||
len *= 2;
|
len *= 2;
|
||||||
val = tvb_memdup(wmem_packet_scope(), tvb, offset2, len);
|
val = tvb_memdup(wmem_packet_scope(), tvb, offset2, len);
|
||||||
val2 = wmem_strbuf_sized_new(wmem_packet_scope(), len/2+1, 0);
|
val2 = wmem_strbuf_new_sized(wmem_packet_scope(), len/2+1);
|
||||||
|
|
||||||
for(j = 0, k = 0; j < len; j += 2, k++) {
|
for(j = 0, k = 0; j < len; j += 2, k++) {
|
||||||
val[j] ^= 0xA5;
|
val[j] ^= 0xA5;
|
||||||
|
|
|
@ -641,8 +641,7 @@ add_ring_bridge_pairs(int rcf_len, tvbuff_t *tvb, proto_tree *tree)
|
||||||
wmem_strbuf_t *buf;
|
wmem_strbuf_t *buf;
|
||||||
#define MAX_BUF_LEN 3 + (RIF_BYTES_TO_PROCESS / 2) * 6 + 1
|
#define MAX_BUF_LEN 3 + (RIF_BYTES_TO_PROCESS / 2) * 6 + 1
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(wmem_packet_scope(),
|
buf = wmem_strbuf_new_sized(wmem_packet_scope(), MAX_BUF_LEN);
|
||||||
MAX_BUF_LEN, MAX_BUF_LEN);
|
|
||||||
/* Only process so many bytes of RIF, as per TR spec, and not overflow
|
/* Only process so many bytes of RIF, as per TR spec, and not overflow
|
||||||
* static buffer above */
|
* static buffer above */
|
||||||
unprocessed_rif = rcf_len - RIF_BYTES_TO_PROCESS;
|
unprocessed_rif = rcf_len - RIF_BYTES_TO_PROCESS;
|
||||||
|
|
|
@ -492,7 +492,7 @@ static void dissect_wa_payload(guint32 starting_offset, proto_item *parent_tree,
|
||||||
offset = starting_offset + 16;
|
offset = starting_offset + 16;
|
||||||
delta = 148;
|
delta = 148;
|
||||||
|
|
||||||
sb = wmem_strbuf_sized_new(wmem_packet_scope(), 8, SHORT_STR);
|
sb = wmem_strbuf_new_sized(wmem_packet_scope(), 8);
|
||||||
|
|
||||||
for (iLoop = 0; iLoop < num_bss_entries; iLoop++)
|
for (iLoop = 0; iLoop < num_bss_entries; iLoop++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2231,7 +2231,7 @@ static char *tvb_get_ascii_string16(tvbuff_t *tvb, int offset, guint length)
|
||||||
wmem_strbuf_t *str;
|
wmem_strbuf_t *str;
|
||||||
guint8 ch;
|
guint8 ch;
|
||||||
|
|
||||||
str = wmem_strbuf_sized_new(wmem_packet_scope(), length + 1, 0);
|
str = wmem_strbuf_new_sized(wmem_packet_scope(), length + 1);
|
||||||
|
|
||||||
while(length--) {
|
while(length--) {
|
||||||
offset++;
|
offset++;
|
||||||
|
|
|
@ -862,7 +862,7 @@ dissect_x509if_RelativeDistinguishedName(gboolean implicit_tag _U_, tvbuff_t *tv
|
||||||
/* now append this to the DN */
|
/* now append this to the DN */
|
||||||
if (last_dn_buf) {
|
if (last_dn_buf) {
|
||||||
if(wmem_strbuf_get_len(last_dn_buf) > 0) {
|
if(wmem_strbuf_get_len(last_dn_buf) > 0) {
|
||||||
wmem_strbuf_t *temp_dn_buf = wmem_strbuf_sized_new(actx->pinfo->pool, wmem_strbuf_get_len(last_rdn_buf) + wmem_strbuf_get_len(last_dn_buf) + 1, 0);
|
wmem_strbuf_t *temp_dn_buf = wmem_strbuf_new_sized(actx->pinfo->pool, wmem_strbuf_get_len(last_rdn_buf) + wmem_strbuf_get_len(last_dn_buf) + 1);
|
||||||
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_rdn_buf));
|
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_rdn_buf));
|
||||||
wmem_strbuf_append_c(temp_dn_buf, ',');
|
wmem_strbuf_append_c(temp_dn_buf, ',');
|
||||||
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_dn_buf));
|
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_dn_buf));
|
||||||
|
|
|
@ -412,8 +412,7 @@ construct_dag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *xip_tree,
|
||||||
ti = proto_tree_add_item(xip_tree, hf, tvb, offset,
|
ti = proto_tree_add_item(xip_tree, hf, tvb, offset,
|
||||||
num_nodes * XIA_NODE_SIZE, ENC_BIG_ENDIAN);
|
num_nodes * XIA_NODE_SIZE, ENC_BIG_ENDIAN);
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(pinfo->pool,
|
buf = wmem_strbuf_new_sized(pinfo->pool, XIA_MAX_STRADDR_SIZE);
|
||||||
XIA_MAX_STRADDR_SIZE, XIA_MAX_STRADDR_SIZE);
|
|
||||||
|
|
||||||
dag_tree = proto_item_add_subtree(ti, ett);
|
dag_tree = proto_item_add_subtree(ti, ett);
|
||||||
|
|
||||||
|
|
|
@ -8044,7 +8044,7 @@ proto_list_layers(const packet_info *pinfo)
|
||||||
wmem_strbuf_t *buf;
|
wmem_strbuf_t *buf;
|
||||||
wmem_list_frame_t *layers = wmem_list_head(pinfo->layers);
|
wmem_list_frame_t *layers = wmem_list_head(pinfo->layers);
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(pinfo->pool, 128, 0);
|
buf = wmem_strbuf_new_sized(pinfo->pool, 128);
|
||||||
|
|
||||||
/* Walk the list of layers in the packet and
|
/* Walk the list of layers in the packet and
|
||||||
return a string of all entries. */
|
return a string of all entries. */
|
||||||
|
|
|
@ -423,7 +423,7 @@ unsigned_time_secs_to_str(wmem_allocator_t *scope, const guint32 time_val)
|
||||||
return wmem_strdup(scope, "0 seconds");
|
return wmem_strdup(scope, "0 seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(scope, TIME_SECS_LEN+1, TIME_SECS_LEN+1);
|
buf = wmem_strbuf_new_sized(scope, TIME_SECS_LEN+1);
|
||||||
|
|
||||||
unsigned_time_secs_to_str_buf(time_val, 0, FALSE, buf);
|
unsigned_time_secs_to_str_buf(time_val, 0, FALSE, buf);
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ signed_time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val)
|
||||||
return wmem_strdup(scope, "0 seconds");
|
return wmem_strdup(scope, "0 seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(scope, TIME_SECS_LEN+1, TIME_SECS_LEN+1);
|
buf = wmem_strbuf_new_sized(scope, TIME_SECS_LEN+1);
|
||||||
|
|
||||||
signed_time_secs_to_str_buf(time_val, 0, FALSE, buf);
|
signed_time_secs_to_str_buf(time_val, 0, FALSE, buf);
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ signed_time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val)
|
||||||
return wmem_strdup(scope, "0 seconds");
|
return wmem_strdup(scope, "0 seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(scope, TIME_SECS_LEN+1+3+1, TIME_SECS_LEN+1+3+1);
|
buf = wmem_strbuf_new_sized(scope, TIME_SECS_LEN+1+3+1);
|
||||||
|
|
||||||
if (time_val<0) {
|
if (time_val<0) {
|
||||||
/* oops we got passed a negative time */
|
/* oops we got passed a negative time */
|
||||||
|
@ -537,7 +537,7 @@ rel_time_to_str(wmem_allocator_t *scope, const nstime_t *rel_time)
|
||||||
return wmem_strdup(scope, "0.000000000 seconds");
|
return wmem_strdup(scope, "0.000000000 seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(scope, 1+TIME_SECS_LEN+1+6+1, 1+TIME_SECS_LEN+1+6+1);
|
buf = wmem_strbuf_new_sized(scope, 1+TIME_SECS_LEN+1+6+1);
|
||||||
|
|
||||||
if (nsec < 0) {
|
if (nsec < 0) {
|
||||||
nsec = -nsec;
|
nsec = -nsec;
|
||||||
|
|
|
@ -3033,7 +3033,7 @@ tvb_get_apn_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset,
|
||||||
* the upper 2 bits of the length don't indicate that it's a
|
* the upper 2 bits of the length don't indicate that it's a
|
||||||
* pointer or an extended label (RFC 2673).
|
* pointer or an extended label (RFC 2673).
|
||||||
*/
|
*/
|
||||||
str = wmem_strbuf_sized_new(scope, length + 1, 0);
|
str = wmem_strbuf_new_sized(scope, length + 1);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
const guint8 *ptr;
|
const guint8 *ptr;
|
||||||
|
|
||||||
|
|
|
@ -492,7 +492,7 @@ escape_string_len(wmem_allocator_t *alloc, const char *string, ssize_t len,
|
||||||
if (add_quotes)
|
if (add_quotes)
|
||||||
alloc_size += 2;
|
alloc_size += 2;
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(alloc, alloc_size, 0);
|
buf = wmem_strbuf_new_sized(alloc, alloc_size);
|
||||||
|
|
||||||
if (add_quotes)
|
if (add_quotes)
|
||||||
wmem_strbuf_append_c(buf, '"');
|
wmem_strbuf_append_c(buf, '"');
|
||||||
|
@ -552,7 +552,7 @@ ws_strdup_underline(wmem_allocator_t *allocator, long offset, size_t len)
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
wmem_strbuf_t *buf = wmem_strbuf_sized_new(allocator, offset + len, 0);
|
wmem_strbuf_t *buf = wmem_strbuf_new_sized(allocator, offset + len);
|
||||||
|
|
||||||
for (int i = 0; i < offset; i++) {
|
for (int i = 0; i < offset; i++) {
|
||||||
wmem_strbuf_append_c(buf, ' ');
|
wmem_strbuf_append_c(buf, ' ');
|
||||||
|
@ -1013,7 +1013,7 @@ format_text_chr(wmem_allocator_t *allocator, const char *string, size_t len, cha
|
||||||
{
|
{
|
||||||
wmem_strbuf_t *buf;
|
wmem_strbuf_t *buf;
|
||||||
|
|
||||||
buf = wmem_strbuf_sized_new(allocator, len + 1, 0);
|
buf = wmem_strbuf_new_sized(allocator, len + 1);
|
||||||
for (const char *p = string; p < string + len; p++) {
|
for (const char *p = string; p < string + len; p++) {
|
||||||
if (g_ascii_isprint(*p)) {
|
if (g_ascii_isprint(*p)) {
|
||||||
wmem_strbuf_append_c(buf, *p);
|
wmem_strbuf_append_c(buf, *p);
|
||||||
|
|
|
@ -26,19 +26,16 @@
|
||||||
#define WMEM_STRBUF_RAW_ROOM(S) ((S)->alloc_size - (S)->len)
|
#define WMEM_STRBUF_RAW_ROOM(S) ((S)->alloc_size - (S)->len)
|
||||||
|
|
||||||
wmem_strbuf_t *
|
wmem_strbuf_t *
|
||||||
wmem_strbuf_sized_new(wmem_allocator_t *allocator,
|
wmem_strbuf_new_sized(wmem_allocator_t *allocator,
|
||||||
size_t alloc_size, size_t max_size)
|
size_t alloc_size)
|
||||||
{
|
{
|
||||||
wmem_strbuf_t *strbuf;
|
wmem_strbuf_t *strbuf;
|
||||||
|
|
||||||
ASSERT((max_size == 0) || (alloc_size <= max_size));
|
|
||||||
|
|
||||||
strbuf = wmem_new(allocator, wmem_strbuf_t);
|
strbuf = wmem_new(allocator, wmem_strbuf_t);
|
||||||
|
|
||||||
strbuf->allocator = allocator;
|
strbuf->allocator = allocator;
|
||||||
strbuf->len = 0;
|
strbuf->len = 0;
|
||||||
strbuf->alloc_size = alloc_size ? alloc_size : DEFAULT_MINIMUM_SIZE;
|
strbuf->alloc_size = alloc_size ? alloc_size : DEFAULT_MINIMUM_SIZE;
|
||||||
strbuf->max_size = max_size;
|
|
||||||
|
|
||||||
strbuf->str = (gchar *)wmem_alloc(strbuf->allocator, strbuf->alloc_size);
|
strbuf->str = (gchar *)wmem_alloc(strbuf->allocator, strbuf->alloc_size);
|
||||||
strbuf->str[0] = '\0';
|
strbuf->str[0] = '\0';
|
||||||
|
@ -59,7 +56,7 @@ wmem_strbuf_new_len(wmem_allocator_t *allocator, const gchar *str, size_t len)
|
||||||
alloc_size *= 2;
|
alloc_size *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(allocator, alloc_size, 0);
|
strbuf = wmem_strbuf_new_sized(allocator, alloc_size);
|
||||||
|
|
||||||
if (str && len > 0) {
|
if (str && len > 0) {
|
||||||
ASSERT(strbuf->alloc_size >= len + 1);
|
ASSERT(strbuf->alloc_size >= len + 1);
|
||||||
|
@ -82,7 +79,7 @@ wmem_strbuf_dup(wmem_allocator_t *allocator, const wmem_strbuf_t *src)
|
||||||
{
|
{
|
||||||
wmem_strbuf_t *new;
|
wmem_strbuf_t *new;
|
||||||
|
|
||||||
new = wmem_strbuf_sized_new(allocator, src->alloc_size, src->max_size);
|
new = wmem_strbuf_new_sized(allocator, src->alloc_size);
|
||||||
new->len = src->len;
|
new->len = src->len;
|
||||||
memcpy(new->str, src->str, new->len);
|
memcpy(new->str, src->str, new->len);
|
||||||
new->str[new->len] = '\0';
|
new->str[new->len] = '\0';
|
||||||
|
@ -112,11 +109,6 @@ wmem_strbuf_grow(wmem_strbuf_t *strbuf, const size_t to_add)
|
||||||
new_alloc_len *= 2;
|
new_alloc_len *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* max length only enforced if not 0 */
|
|
||||||
if (strbuf->max_size && new_alloc_len > strbuf->max_size) {
|
|
||||||
new_alloc_len = strbuf->max_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_alloc_len == strbuf->alloc_size) {
|
if (new_alloc_len == strbuf->alloc_size) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -154,17 +146,13 @@ wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const gchar *str, size_t append_le
|
||||||
|
|
||||||
wmem_strbuf_grow(strbuf, append_len);
|
wmem_strbuf_grow(strbuf, append_len);
|
||||||
|
|
||||||
if (strbuf->max_size) {
|
|
||||||
append_len = MIN(append_len, WMEM_STRBUF_ROOM(strbuf));
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&strbuf->str[strbuf->len], str, append_len);
|
memcpy(&strbuf->str[strbuf->len], str, append_len);
|
||||||
strbuf->len += append_len;
|
strbuf->len += append_len;
|
||||||
strbuf->str[strbuf->len] = '\0';
|
strbuf->str[strbuf->len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
int _strbuf_vsnprintf(wmem_strbuf_t *strbuf, const char *format, va_list ap, gboolean reset)
|
int _strbuf_vsnprintf(wmem_strbuf_t *strbuf, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
int want_len;
|
int want_len;
|
||||||
char *buffer = &strbuf->str[strbuf->len];
|
char *buffer = &strbuf->str[strbuf->len];
|
||||||
|
@ -182,14 +170,8 @@ int _strbuf_vsnprintf(wmem_strbuf_t *strbuf, const char *format, va_list ap, gbo
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No space in buffer, output was truncated. */
|
/* Not enough space in buffer, output was truncated. */
|
||||||
if (reset) {
|
strbuf->str[strbuf->len] = '\0'; /* Reset. */
|
||||||
strbuf->str[strbuf->len] = '\0'; /* Reset. */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
strbuf->len += buffer_size - 1; /* Append. */
|
|
||||||
ASSERT(strbuf->len == strbuf->alloc_size - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return want_len; /* Length (not including terminating null) that would be written
|
return want_len; /* Length (not including terminating null) that would be written
|
||||||
if there was enough space in buffer. */
|
if there was enough space in buffer. */
|
||||||
|
@ -203,14 +185,16 @@ wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const gchar *fmt, va_list ap)
|
||||||
|
|
||||||
va_copy(ap2, ap);
|
va_copy(ap2, ap);
|
||||||
/* Try to write buffer, check if output fits. */
|
/* Try to write buffer, check if output fits. */
|
||||||
want_len = _strbuf_vsnprintf(strbuf, fmt, ap2, TRUE); /* Remove output if truncated. */
|
want_len = _strbuf_vsnprintf(strbuf, fmt, ap2);
|
||||||
va_end(ap2);
|
va_end(ap2);
|
||||||
if (want_len <= 0)
|
if (want_len <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Resize buffer and try again. This could hit the 'max_size' ceiling. */
|
/* Resize buffer and try again. */
|
||||||
wmem_strbuf_grow(strbuf, want_len);
|
wmem_strbuf_grow(strbuf, want_len);
|
||||||
_strbuf_vsnprintf(strbuf, fmt, ap, FALSE); /* Keep output if truncated. */
|
want_len = _strbuf_vsnprintf(strbuf, fmt, ap);
|
||||||
|
/* Second time must succeed or error out. */
|
||||||
|
ASSERT(want_len <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -228,7 +212,7 @@ wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const gchar c)
|
||||||
{
|
{
|
||||||
wmem_strbuf_grow(strbuf, 1);
|
wmem_strbuf_grow(strbuf, 1);
|
||||||
|
|
||||||
if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= 1) {
|
if (WMEM_STRBUF_ROOM(strbuf) >= 1) {
|
||||||
strbuf->str[strbuf->len] = c;
|
strbuf->str[strbuf->len] = c;
|
||||||
strbuf->len++;
|
strbuf->len++;
|
||||||
strbuf->str[strbuf->len] = '\0';
|
strbuf->str[strbuf->len] = '\0';
|
||||||
|
@ -245,7 +229,7 @@ wmem_strbuf_append_unichar(wmem_strbuf_t *strbuf, const gunichar c)
|
||||||
|
|
||||||
wmem_strbuf_grow(strbuf, charlen);
|
wmem_strbuf_grow(strbuf, charlen);
|
||||||
|
|
||||||
if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= charlen) {
|
if (WMEM_STRBUF_ROOM(strbuf) >= charlen) {
|
||||||
memcpy(&strbuf->str[strbuf->len], buf, charlen);
|
memcpy(&strbuf->str[strbuf->len], buf, charlen);
|
||||||
strbuf->len += charlen;
|
strbuf->len += charlen;
|
||||||
strbuf->str[strbuf->len] = '\0';
|
strbuf->str[strbuf->len] = '\0';
|
||||||
|
@ -272,7 +256,7 @@ wmem_strbuf_append_hex(wmem_strbuf_t *strbuf, uint8_t ch)
|
||||||
{
|
{
|
||||||
wmem_strbuf_grow(strbuf, HEX_CODELEN * 1);
|
wmem_strbuf_grow(strbuf, HEX_CODELEN * 1);
|
||||||
|
|
||||||
if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= HEX_CODELEN * 1) {
|
if (WMEM_STRBUF_ROOM(strbuf) >= HEX_CODELEN * 1) {
|
||||||
strbuf->str[strbuf->len++] = '\\';
|
strbuf->str[strbuf->len++] = '\\';
|
||||||
strbuf->str[strbuf->len++] = 'x';
|
strbuf->str[strbuf->len++] = 'x';
|
||||||
strbuf->str[strbuf->len++] = hex[(ch >> 4) & 0xF];
|
strbuf->str[strbuf->len++] = hex[(ch >> 4) & 0xF];
|
||||||
|
@ -288,7 +272,7 @@ void append_hex_bmp(wmem_strbuf_t *strbuf, gunichar ch)
|
||||||
{
|
{
|
||||||
wmem_strbuf_grow(strbuf, BMP_CODELEN * 1);
|
wmem_strbuf_grow(strbuf, BMP_CODELEN * 1);
|
||||||
|
|
||||||
if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= BMP_CODELEN * 1) {
|
if (WMEM_STRBUF_ROOM(strbuf) >= BMP_CODELEN * 1) {
|
||||||
strbuf->str[strbuf->len++] = '\\';
|
strbuf->str[strbuf->len++] = '\\';
|
||||||
strbuf->str[strbuf->len++] = 'u';
|
strbuf->str[strbuf->len++] = 'u';
|
||||||
strbuf->str[strbuf->len++] = hex[(ch >> 12) & 0xF];
|
strbuf->str[strbuf->len++] = hex[(ch >> 12) & 0xF];
|
||||||
|
@ -306,7 +290,7 @@ void append_hex_any(wmem_strbuf_t *strbuf, gunichar ch)
|
||||||
{
|
{
|
||||||
wmem_strbuf_grow(strbuf, ANY_CODELEN * 1);
|
wmem_strbuf_grow(strbuf, ANY_CODELEN * 1);
|
||||||
|
|
||||||
if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= ANY_CODELEN * 1) {
|
if (WMEM_STRBUF_ROOM(strbuf) >= ANY_CODELEN * 1) {
|
||||||
strbuf->str[strbuf->len++] = '\\';
|
strbuf->str[strbuf->len++] = '\\';
|
||||||
strbuf->str[strbuf->len++] = 'U';
|
strbuf->str[strbuf->len++] = 'U';
|
||||||
strbuf->str[strbuf->len++] = hex[(ch >> 28) & 0xF];
|
strbuf->str[strbuf->len++] = hex[(ch >> 28) & 0xF];
|
||||||
|
|
|
@ -47,15 +47,13 @@ struct _wmem_strbuf_t {
|
||||||
|
|
||||||
/* private fields */
|
/* private fields */
|
||||||
size_t alloc_size;
|
size_t alloc_size;
|
||||||
size_t max_size;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _wmem_strbuf_t wmem_strbuf_t;
|
typedef struct _wmem_strbuf_t wmem_strbuf_t;
|
||||||
|
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
wmem_strbuf_t *
|
wmem_strbuf_t *
|
||||||
wmem_strbuf_sized_new(wmem_allocator_t *allocator,
|
wmem_strbuf_new_sized(wmem_allocator_t *allocator, size_t alloc_size)
|
||||||
size_t alloc_size, size_t max_size)
|
|
||||||
G_GNUC_MALLOC;
|
G_GNUC_MALLOC;
|
||||||
|
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
|
|
|
@ -1088,7 +1088,6 @@ wmem_test_strbuf(void)
|
||||||
wmem_allocator_t *allocator;
|
wmem_allocator_t *allocator;
|
||||||
wmem_strbuf_t *strbuf;
|
wmem_strbuf_t *strbuf;
|
||||||
int i;
|
int i;
|
||||||
char *str;
|
|
||||||
|
|
||||||
allocator = wmem_allocator_new(WMEM_ALLOCATOR_STRICT);
|
allocator = wmem_allocator_new(WMEM_ALLOCATOR_STRICT);
|
||||||
|
|
||||||
|
@ -1128,35 +1127,6 @@ wmem_test_strbuf(void)
|
||||||
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "TESTFUZZ");
|
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "TESTFUZZ");
|
||||||
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 8);
|
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 8);
|
||||||
|
|
||||||
strbuf = wmem_strbuf_sized_new(allocator, 10, 10);
|
|
||||||
g_assert_true(strbuf);
|
|
||||||
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "");
|
|
||||||
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 0);
|
|
||||||
|
|
||||||
wmem_strbuf_append(strbuf, "FUZZ");
|
|
||||||
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ");
|
|
||||||
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 4);
|
|
||||||
|
|
||||||
wmem_strbuf_append_printf(strbuf, "%d%s", 3, "abcdefghijklmnop");
|
|
||||||
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ3abcd");
|
|
||||||
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 9);
|
|
||||||
|
|
||||||
wmem_strbuf_append(strbuf, "abcdefghijklmnopqrstuvwxyz");
|
|
||||||
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ3abcd");
|
|
||||||
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 9);
|
|
||||||
|
|
||||||
wmem_strbuf_append_c(strbuf, 'q');
|
|
||||||
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ3abcd");
|
|
||||||
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 9);
|
|
||||||
|
|
||||||
wmem_strbuf_append_unichar(strbuf, g_utf8_get_char("\xC2\xA9"));
|
|
||||||
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ3abcd");
|
|
||||||
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 9);
|
|
||||||
|
|
||||||
str = wmem_strbuf_finalize(strbuf);
|
|
||||||
g_assert_cmpstr(str, ==, "FUZZ3abcd");
|
|
||||||
g_assert_cmpuint(strlen(str), ==, 9);
|
|
||||||
|
|
||||||
wmem_free_all(allocator);
|
wmem_free_all(allocator);
|
||||||
|
|
||||||
strbuf = wmem_strbuf_new(allocator, "TEST");
|
strbuf = wmem_strbuf_new(allocator, "TEST");
|
||||||
|
|
Loading…
Reference in New Issue