UAT: HEX Values should be allowed the full uint32 range e.g allow 0xffffffff
Change-Id: I13ec13646271bd9de543d02de5c7cbc0d6d02019 Reviewed-on: https://code.wireshark.org/review/29219 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
7d76d0ce28
commit
c57a52f68c
18
epan/uat.c
18
epan/uat.c
|
@ -643,7 +643,23 @@ gboolean uat_fld_chk_num_dec(void* u1 _U_, const char* strptr, guint len, const
|
|||
}
|
||||
|
||||
gboolean uat_fld_chk_num_hex(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, char** err) {
|
||||
return uat_fld_chk_num(16, strptr, len, err);
|
||||
if (len > 0) {
|
||||
char* str = g_strndup(strptr, len);
|
||||
gboolean result;
|
||||
guint32 value;
|
||||
|
||||
errno = 0;
|
||||
result = ws_hexstrtou32(str, NULL, &value);
|
||||
if (errno != 0) {
|
||||
*err = g_strdup(g_strerror(errno));
|
||||
}
|
||||
g_free(str);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
*err = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean uat_fld_chk_bool(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, char** err)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "ws_symbol_export.h"
|
||||
#include <wsutil/strtoi.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -532,7 +533,7 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr,
|
|||
#define UAT_HEX_CB_DEF(basename,field_name,rec_t) \
|
||||
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
char* tmp_str = g_strndup(buf,len); \
|
||||
((rec_t*)rec)->field_name = (guint)strtol(tmp_str,NULL,16); \
|
||||
ws_hexstrtou32(tmp_str, NULL, &((rec_t*)rec)->field_name); \
|
||||
g_free(tmp_str); } \
|
||||
static void basename ## _ ## field_name ## _tostr_cb(void* rec, char** out_ptr, unsigned* out_len, const void* UNUSED_PARAMETER(u1), const void* UNUSED_PARAMETER(u2)) {\
|
||||
*out_ptr = g_strdup_printf("%x",((rec_t*)rec)->field_name); \
|
||||
|
|
Loading…
Reference in New Issue