forked from osmocom/wireshark
UAT error string pointers should not be const pointers.
UAT error strings are usually allocated by g_strdup() or g_strdup_printf(), and must ultimately be freed by the caller. Make the pointer-to-error-string-pointer arguments to various functions be "char **", not "const char **". Fix cases that finds where a raw string was being used, as that won't work if you try to free it; g_strdup() it instead. Add a missing free of an error string. Remove some no-longer-necessary casts. Remove some unnecessary g_strdup()s (the string being handed to it was already g_malloc()ated). Change some variable declarations to match. Put in XXX comments for some cases where the error string is just freed, without being shown to the user. Change-Id: I40297746a2ef729c56763baeddbb0842386fa0d0 Reviewed-on: https://code.wireshark.org/review/6525 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
a988253fef
commit
bc23f79729
|
@ -724,7 +724,7 @@ encode_ber_len(guint8 *ptr, guint32 n, int maxsize)
|
|||
* \param err is updated to point to an error string if needed
|
||||
*/
|
||||
static void
|
||||
c1222_uat_data_update_cb(void* n, const char** err)
|
||||
c1222_uat_data_update_cb(void* n, char** err)
|
||||
{
|
||||
c1222_uat_data_t* new_rec = (c1222_uat_data_t *)n;
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ static guint num_attribute_types = 0;
|
|||
static GHashTable* attribute_types_hash = NULL;
|
||||
|
||||
static void
|
||||
attribute_types_update_cb(void *r, const char **err)
|
||||
attribute_types_update_cb(void *r, char **err)
|
||||
{
|
||||
attribute_type_t *rec = (attribute_type_t *)r;
|
||||
char c;
|
||||
|
|
|
@ -1369,7 +1369,7 @@ snmp_users_free_cb(void* p)
|
|||
}
|
||||
|
||||
static void
|
||||
snmp_users_update_cb(void* p _U_, const char** err)
|
||||
snmp_users_update_cb(void* p _U_, char** err)
|
||||
{
|
||||
snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
|
||||
GString* es = g_string_new("");
|
||||
|
|
|
@ -388,7 +388,7 @@ const gchar* dfilter_macro_apply(const gchar* text, const gchar** error) {
|
|||
return dfilter_macro_apply_recurse(text, 0, error);
|
||||
}
|
||||
|
||||
static void macro_update(void* mp, const gchar** error) {
|
||||
static void macro_update(void* mp, gchar** error) {
|
||||
dfilter_macro_t* m = (dfilter_macro_t*)mp;
|
||||
GPtrArray* parts;
|
||||
GArray* args_pos;
|
||||
|
@ -576,7 +576,7 @@ static void* macro_copy(void* dest, const void* orig, size_t len _U_) {
|
|||
return d;
|
||||
}
|
||||
|
||||
static gboolean macro_name_chk(void* r _U_, const char* in_name, guint name_len, const void* u1 _U_, const void* u2 _U_, const char** error) {
|
||||
static gboolean macro_name_chk(void* r _U_, const char* in_name, guint name_len, const void* u1 _U_, const void* u2 _U_, char** error) {
|
||||
guint i;
|
||||
|
||||
if (name_len == 0) {
|
||||
|
|
|
@ -1213,7 +1213,7 @@ static void* uat_bootp_record_copy_cb(void* n, const void* o, size_t siz _U_) {
|
|||
return new_record;
|
||||
}
|
||||
|
||||
static void uat_bootp_record_update_cb(void* r, const char** err) {
|
||||
static void uat_bootp_record_update_cb(void* r, char** err) {
|
||||
uat_bootp_record_t* rec = (uat_bootp_record_t *)r;
|
||||
|
||||
if ((rec->opt == 0) || (rec->opt >=BOOTP_OPT_NUM-1))
|
||||
|
|
|
@ -775,7 +775,7 @@ encode_ber_len(guint8 *ptr, guint32 n, int maxsize)
|
|||
* \param err is updated to point to an error string if needed
|
||||
*/
|
||||
static void
|
||||
c1222_uat_data_update_cb(void* n, const char** err)
|
||||
c1222_uat_data_update_cb(void* n, char** err)
|
||||
{
|
||||
c1222_uat_data_t* new_rec = (c1222_uat_data_t *)n;
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ static uat_devicenet_record_t *uat_devicenet_records = NULL;
|
|||
static uat_t *devicenet_uat = NULL;
|
||||
static guint num_devicenet_records_uat = 0;
|
||||
|
||||
static void uat_devicenet_record_update_cb(void* r, const char** err) {
|
||||
static void uat_devicenet_record_update_cb(void* r, char** err) {
|
||||
uat_devicenet_record_t* rec = (uat_devicenet_record_t *)r;
|
||||
|
||||
if (rec->mac_id > 63)
|
||||
|
|
|
@ -150,7 +150,7 @@ static guint num_header_fields = 0;
|
|||
static GHashTable* header_fields_hash = NULL;
|
||||
|
||||
static void
|
||||
header_fields_update_cb(void *r, const char **err)
|
||||
header_fields_update_cb(void *r, char **err)
|
||||
{
|
||||
header_field_t *rec = (header_field_t *)r;
|
||||
char c;
|
||||
|
|
|
@ -177,7 +177,7 @@ uat_wep_key_record_copy_cb(void* n, const void* o, size_t siz _U_)
|
|||
}
|
||||
|
||||
static void
|
||||
uat_wep_key_record_update_cb(void* r, const char** err)
|
||||
uat_wep_key_record_update_cb(void* r, char** err)
|
||||
{
|
||||
uat_wep_key_record_t* rec = (uat_wep_key_record_t *)r;
|
||||
decryption_key_t* dk;
|
||||
|
|
|
@ -127,7 +127,7 @@ static guint num_static_addrs = 0;
|
|||
|
||||
/* Sanity-checks a UAT record. */
|
||||
static void
|
||||
addr_uat_update_cb(void *r, const char **err)
|
||||
addr_uat_update_cb(void *r, char **err)
|
||||
{
|
||||
static_addr_t *map = (static_addr_t *)r;
|
||||
/* Ensure a valid short address */
|
||||
|
|
|
@ -276,7 +276,7 @@ static guint num_header_fields = 0;
|
|||
static GHashTable *custom_field_table = NULL;
|
||||
|
||||
static void
|
||||
header_fields_update_cb(void *r, const char **err)
|
||||
header_fields_update_cb(void *r, char **err)
|
||||
{
|
||||
header_field_t *rec = (header_field_t *)r;
|
||||
char c;
|
||||
|
|
|
@ -354,7 +354,7 @@ compute_ascii_key(gchar **ascii_key, const gchar *key)
|
|||
}
|
||||
|
||||
|
||||
static void uat_esp_sa_record_update_cb(void* r, const char** err _U_) {
|
||||
static void uat_esp_sa_record_update_cb(void* r, char** err _U_) {
|
||||
uat_esp_sa_record_t* rec = (uat_esp_sa_record_t *)r;
|
||||
|
||||
/* Compute keys & lengths once and for all */
|
||||
|
|
|
@ -4994,7 +4994,7 @@ isakmp_prefs_apply_cb(void) {
|
|||
UAT_BUFFER_CB_DEF(ikev1_users, icookie, ikev1_uat_data_key_t, icookie, icookie_len)
|
||||
UAT_BUFFER_CB_DEF(ikev1_users, key, ikev1_uat_data_key_t, key, key_len)
|
||||
|
||||
static void ikev1_uat_data_update_cb(void* p, const char** err) {
|
||||
static void ikev1_uat_data_update_cb(void* p, char** err) {
|
||||
ikev1_uat_data_key_t *ud = (ikev1_uat_data_key_t *)p;
|
||||
|
||||
if (ud->icookie_len != COOKIE_SIZE) {
|
||||
|
@ -5023,7 +5023,7 @@ UAT_BUFFER_CB_DEF(ikev2_users, sk_ai, ikev2_uat_data_t, sk_ai, sk_ai_len)
|
|||
UAT_BUFFER_CB_DEF(ikev2_users, sk_ar, ikev2_uat_data_t, sk_ar, sk_ar_len)
|
||||
UAT_VS_DEF(ikev2_users, auth_alg, ikev2_uat_data_t, guint, IKEV2_AUTH_HMAC_SHA1_96, IKEV2_AUTH_HMAC_SHA1_96_STR)
|
||||
|
||||
static void ikev2_uat_data_update_cb(void* p, const char** err) {
|
||||
static void ikev2_uat_data_update_cb(void* p, char** err) {
|
||||
ikev2_uat_data_t *ud = (ikev2_uat_data_t *)p;
|
||||
|
||||
if (ud->key.spii_len != COOKIE_SIZE) {
|
||||
|
|
|
@ -297,7 +297,7 @@ dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree)
|
|||
}
|
||||
|
||||
static void
|
||||
k12_update_cb(void* r, const char** err)
|
||||
k12_update_cb(void* r, char** err)
|
||||
{
|
||||
k12_handles_t* h = (k12_handles_t *)r;
|
||||
gchar** protos;
|
||||
|
@ -356,7 +356,7 @@ k12_free_cb(void* r)
|
|||
|
||||
|
||||
static gboolean
|
||||
protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const void* u2 _U_, const char** err)
|
||||
protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const void* u2 _U_, char** err)
|
||||
{
|
||||
gchar** protos;
|
||||
gchar* line = wmem_strndup(NULL,p,len);
|
||||
|
|
|
@ -107,12 +107,12 @@ typedef guint64 lbm_uint64_t;
|
|||
|
||||
/* UAT macros for IPV4 fields. */
|
||||
#define UAT_IPV4_CB_DEF(basename,field_name,rec_t) \
|
||||
static gboolean basename ## _ ## field_name ## _chk_cb(void * u1 _U_, const char * strptr, unsigned len _U_, const void * u2 _U_, const void * u3 _U_, const char ** err) \
|
||||
static gboolean basename ## _ ## field_name ## _chk_cb(void * u1 _U_, const char * strptr, unsigned len _U_, const void * u2 _U_, const void * u3 _U_, char ** err) \
|
||||
{ \
|
||||
struct in_addr addr; \
|
||||
if (inet_aton(strptr, &addr) == 0) \
|
||||
{ \
|
||||
*err = "invalid address"; \
|
||||
*err = g_strdup("invalid address"); \
|
||||
return (FALSE); \
|
||||
} \
|
||||
return (TRUE); \
|
||||
|
@ -145,7 +145,7 @@ typedef guint64 lbm_uint64_t;
|
|||
|
||||
/* UAT macros for IPV4 Multicast fields. */
|
||||
#define UAT_IPV4_MC_CB_DEF(basename,field_name,rec_t) \
|
||||
static gboolean basename ## _ ## field_name ## _chk_cb(void * u1 _U_, const char * strptr, unsigned len _U_, const void * u2 _U_, const void * u3 _U_, const char ** err) \
|
||||
static gboolean basename ## _ ## field_name ## _chk_cb(void * u1 _U_, const char * strptr, unsigned len _U_, const void * u2 _U_, const void * u3 _U_, char ** err) \
|
||||
{ \
|
||||
struct in_addr addr; \
|
||||
if (inet_aton(strptr, &addr) == 0) \
|
||||
|
|
|
@ -153,7 +153,7 @@ static uat_field_t lbmpdm_tcp_tag_array[] =
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* UAT callback functions. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void lbmpdm_tcp_tag_update_cb(void * record, const char * * error_string)
|
||||
static void lbmpdm_tcp_tag_update_cb(void * record, char * * error_string)
|
||||
{
|
||||
lbmpdm_tcp_tag_entry_t * tag = (lbmpdm_tcp_tag_entry_t *)record;
|
||||
|
||||
|
|
|
@ -1968,7 +1968,7 @@ static uat_field_t lbmr_tag_array[] =
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* UAT callback functions. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void lbmr_tag_update_cb(void * record, const char * * error_string)
|
||||
static void lbmr_tag_update_cb(void * record, char * * error_string)
|
||||
{
|
||||
lbmr_tag_entry_t * tag = (lbmr_tag_entry_t *)record;
|
||||
|
||||
|
|
|
@ -653,7 +653,7 @@ static uat_field_t lbtrm_tag_array[] =
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* UAT callback functions. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void lbtrm_tag_update_cb(void * record, const char * * error_string)
|
||||
static void lbtrm_tag_update_cb(void * record, char * * error_string)
|
||||
{
|
||||
lbtrm_tag_entry_t * tag = (lbtrm_tag_entry_t *)record;
|
||||
|
||||
|
|
|
@ -695,7 +695,7 @@ static uat_field_t lbtru_tag_array[] =
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* UAT callback functions. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void lbtru_tag_update_cb(void * record, const char * * error_string)
|
||||
static void lbtru_tag_update_cb(void * record, char * * error_string)
|
||||
{
|
||||
lbtru_tag_entry_t * tag = (lbtru_tag_entry_t *)record;
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ static uat_field_t lbttcp_tag_array[] =
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* UAT callback functions. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void lbttcp_tag_update_cb(void * record, const char * * error_string)
|
||||
static void lbttcp_tag_update_cb(void * record, char * * error_string)
|
||||
{
|
||||
lbttcp_tag_entry_t * tag = (lbttcp_tag_entry_t *)record;
|
||||
|
||||
|
|
|
@ -620,7 +620,7 @@ static guint num_attribute_types = 0;
|
|||
static GHashTable* attribute_types_hash = NULL;
|
||||
|
||||
static void
|
||||
attribute_types_update_cb(void *r, const char **err)
|
||||
attribute_types_update_cb(void *r, char **err)
|
||||
{
|
||||
attribute_type_t *rec = (attribute_type_t *)r;
|
||||
char c;
|
||||
|
|
|
@ -248,7 +248,7 @@ static void update_key_from_string(const char *stringKey, guint8 *binaryKey, gbo
|
|||
}
|
||||
|
||||
/* Update by checking whether the 3 key strings are valid or not, and storing result */
|
||||
static void uat_ue_keys_record_update_cb(void* record, const char** error _U_) {
|
||||
static void uat_ue_keys_record_update_cb(void* record, char** error _U_) {
|
||||
uat_ue_keys_record_t* rec = (uat_ue_keys_record_t *)record;
|
||||
|
||||
/* Check and convert RRC key */
|
||||
|
|
|
@ -3420,7 +3420,7 @@ static struct _sccp_ul {
|
|||
};
|
||||
|
||||
static void
|
||||
sccp_users_update_cb(void *r, const char **err)
|
||||
sccp_users_update_cb(void *r, char **err)
|
||||
{
|
||||
sccp_user_t *u = (sccp_user_t *)r;
|
||||
struct _sccp_ul *c;
|
||||
|
|
|
@ -539,7 +539,7 @@ sctp_chunk_type_free_cb(void* r)
|
|||
}
|
||||
|
||||
static void
|
||||
sctp_chunk_type_update_cb(void *r, const char **err)
|
||||
sctp_chunk_type_update_cb(void *r, char **err)
|
||||
{
|
||||
type_field_t *rec = (type_field_t *)r;
|
||||
char c;
|
||||
|
|
|
@ -1471,7 +1471,7 @@ snmp_users_free_cb(void* p)
|
|||
}
|
||||
|
||||
static void
|
||||
snmp_users_update_cb(void* p _U_, const char** err)
|
||||
snmp_users_update_cb(void* p _U_, char** err)
|
||||
{
|
||||
snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
|
||||
GString* es = g_string_new("");
|
||||
|
|
|
@ -4812,7 +4812,7 @@ ssl_print_string(const gchar* name, const StringInfo* data)
|
|||
/* checks for SSL and DTLS UAT key list fields */
|
||||
|
||||
gboolean
|
||||
ssldecrypt_uat_fld_ip_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, const char** err)
|
||||
ssldecrypt_uat_fld_ip_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
|
||||
{
|
||||
if (!p || strlen(p) == 0u) {
|
||||
*err = g_strdup_printf("No IP address given.");
|
||||
|
@ -4824,7 +4824,7 @@ ssldecrypt_uat_fld_ip_chk_cb(void* r _U_, const char* p, guint len _U_, const vo
|
|||
}
|
||||
|
||||
gboolean
|
||||
ssldecrypt_uat_fld_port_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, const char** err)
|
||||
ssldecrypt_uat_fld_port_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
|
||||
{
|
||||
if (!p || strlen(p) == 0u) {
|
||||
*err = g_strdup_printf("No Port given.");
|
||||
|
@ -4844,7 +4844,7 @@ ssldecrypt_uat_fld_port_chk_cb(void* r _U_, const char* p, guint len _U_, const
|
|||
}
|
||||
|
||||
gboolean
|
||||
ssldecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, const char** err)
|
||||
ssldecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
|
||||
{
|
||||
if (!p || strlen(p) == 0u) {
|
||||
*err = g_strdup_printf("No protocol given.");
|
||||
|
@ -4863,7 +4863,7 @@ ssldecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, co
|
|||
}
|
||||
|
||||
gboolean
|
||||
ssldecrypt_uat_fld_fileopen_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, const char** err)
|
||||
ssldecrypt_uat_fld_fileopen_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
|
||||
{
|
||||
ws_statb64 st;
|
||||
|
||||
|
@ -4882,7 +4882,7 @@ ssldecrypt_uat_fld_fileopen_chk_cb(void* r _U_, const char* p, guint len _U_, co
|
|||
}
|
||||
|
||||
gboolean
|
||||
ssldecrypt_uat_fld_password_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, const char ** err)
|
||||
ssldecrypt_uat_fld_password_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char ** err)
|
||||
{
|
||||
ssldecrypt_assoc_t* f = (ssldecrypt_assoc_t *)r;
|
||||
FILE *fp = NULL;
|
||||
|
|
|
@ -442,11 +442,11 @@ typedef struct {
|
|||
|
||||
gint ssl_get_keyex_alg(gint cipher);
|
||||
|
||||
gboolean ssldecrypt_uat_fld_ip_chk_cb(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean ssldecrypt_uat_fld_port_chk_cb(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean ssldecrypt_uat_fld_protocol_chk_cb(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean ssldecrypt_uat_fld_fileopen_chk_cb(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean ssldecrypt_uat_fld_password_chk_cb(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean ssldecrypt_uat_fld_ip_chk_cb(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
gboolean ssldecrypt_uat_fld_port_chk_cb(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
gboolean ssldecrypt_uat_fld_protocol_chk_cb(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
gboolean ssldecrypt_uat_fld_fileopen_chk_cb(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
gboolean ssldecrypt_uat_fld_password_chk_cb(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
|
||||
/** Initialize decryption engine/ssl layer. To be called once per execution */
|
||||
extern void
|
||||
|
|
|
@ -183,7 +183,7 @@ static guint num_channels_uat = 0;
|
|||
UAT_DEC_CB_DEF(uat_bitchannels, channel, uat_channel_t)
|
||||
|
||||
static void
|
||||
vcdu_uat_data_update_cb(void *p, const char **err) {
|
||||
vcdu_uat_data_update_cb(void *p, char **err) {
|
||||
uat_channel_t *ud = (uat_channel_t *)p;
|
||||
|
||||
if (ud->channel >= 64) {
|
||||
|
|
|
@ -619,7 +619,7 @@ zbee_gp_security_parse_key(const gchar *key_str, guint8 *key_buf, gboolean byte_
|
|||
|
||||
/* UAT record update callback. */
|
||||
static void
|
||||
uat_key_record_update_cb(void *r, const char **err)
|
||||
uat_key_record_update_cb(void *r, char **err)
|
||||
{
|
||||
uat_key_record_t *rec = (uat_key_record_t *)r;
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ static void* uat_key_record_copy_cb(void* n, const void* o, size_t siz _U_) {
|
|||
return new_key;
|
||||
}
|
||||
|
||||
static void uat_key_record_update_cb(void* r, const char** err) {
|
||||
static void uat_key_record_update_cb(void* r, char** err) {
|
||||
uat_key_record_t* rec = (uat_key_record_t *)r;
|
||||
guint8 key[ZBEE_SEC_CONST_KEYSIZE];
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ static GArray *uat_saved_fields = NULL;
|
|||
UAT_CSTRING_CB_DEF(uat_expert_entries, field, expert_level_entry_t)
|
||||
UAT_VS_DEF(uat_expert_entries, severity, expert_level_entry_t, guint32, PI_ERROR, "Error")
|
||||
|
||||
static void uat_expert_update_cb(void *r, const char **err)
|
||||
static void uat_expert_update_cb(void *r, char **err)
|
||||
{
|
||||
expert_level_entry_t *rec = (expert_level_entry_t *)r;
|
||||
|
||||
|
|
16
epan/uat.c
16
epan/uat.c
|
@ -447,7 +447,7 @@ void uat_load_all(void) {
|
|||
}
|
||||
|
||||
|
||||
gboolean uat_fld_chk_str(void* u1 _U_, const char* strptr, guint len _U_, const void* u2 _U_, const void* u3 _U_, const char** err) {
|
||||
gboolean uat_fld_chk_str(void* u1 _U_, const char* strptr, guint len _U_, const void* u2 _U_, const void* u3 _U_, char** err) {
|
||||
if (strptr == NULL) {
|
||||
*err = g_strdup("NULL pointer");
|
||||
return FALSE;
|
||||
|
@ -457,7 +457,7 @@ gboolean uat_fld_chk_str(void* u1 _U_, const char* strptr, guint len _U_, const
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean uat_fld_chk_oid(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, const char** err) {
|
||||
gboolean uat_fld_chk_oid(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, char** err) {
|
||||
unsigned int i;
|
||||
*err = NULL;
|
||||
|
||||
|
@ -487,7 +487,7 @@ gboolean uat_fld_chk_oid(void* u1 _U_, const char* strptr, guint len, const void
|
|||
return *err == NULL;
|
||||
}
|
||||
|
||||
gboolean uat_fld_chk_proto(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, const char** err) {
|
||||
gboolean uat_fld_chk_proto(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, char** err) {
|
||||
if (len) {
|
||||
char* name = g_strndup(strptr,len);
|
||||
ascii_strdown_inplace(name);
|
||||
|
@ -508,7 +508,7 @@ gboolean uat_fld_chk_proto(void* u1 _U_, const char* strptr, guint len, const vo
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean uat_fld_chk_num(int base, const char* strptr, guint len, const char** err) {
|
||||
static gboolean uat_fld_chk_num(int base, const char* strptr, guint len, char** err) {
|
||||
if (len > 0) {
|
||||
char* str = g_strndup(strptr,len);
|
||||
char* strn;
|
||||
|
@ -542,15 +542,15 @@ static gboolean uat_fld_chk_num(int base, const char* strptr, guint len, const c
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean uat_fld_chk_num_dec(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, const char** err) {
|
||||
gboolean uat_fld_chk_num_dec(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, char** err) {
|
||||
return uat_fld_chk_num(10, strptr, len, err);
|
||||
}
|
||||
|
||||
gboolean uat_fld_chk_num_hex(void* u1 _U_, const char* strptr, guint len, const void* u2 _U_, const void* u3 _U_, const char** err) {
|
||||
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);
|
||||
}
|
||||
|
||||
gboolean uat_fld_chk_enum(void* u1 _U_, const char* strptr, guint len, const void* v, const void* u3 _U_, const char** err) {
|
||||
gboolean uat_fld_chk_enum(void* u1 _U_, const char* strptr, guint len, const void* v, const void* u3 _U_, char** err) {
|
||||
char* str = g_strndup(strptr,len);
|
||||
guint i;
|
||||
const value_string* vs = (const value_string *)v;
|
||||
|
@ -568,7 +568,7 @@ gboolean uat_fld_chk_enum(void* u1 _U_, const char* strptr, guint len, const voi
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean uat_fld_chk_range(void* u1 _U_, const char* strptr, guint len, const void* v _U_, const void* u3, const char** err) {
|
||||
gboolean uat_fld_chk_range(void* u1 _U_, const char* strptr, guint len, const void* v _U_, const void* u3, char** err) {
|
||||
char* str = g_strndup(strptr,len);
|
||||
range_t* r = NULL;
|
||||
convert_ret_t ret = range_convert_str(&r, str,GPOINTER_TO_UINT(u3));
|
||||
|
|
24
epan/uat.h
24
epan/uat.h
|
@ -109,8 +109,10 @@ typedef void (*uat_free_cb_t)(void*);
|
|||
* to be called after any record fields had been updated
|
||||
* optional, record will be updated always if not given
|
||||
* update(record,&error)
|
||||
* The error string must be allocated with g_malloc() or
|
||||
* a routine that calls it.
|
||||
*/
|
||||
typedef void (*uat_update_cb_t)(void* , const char** );
|
||||
typedef void (*uat_update_cb_t)(void* , char** );
|
||||
|
||||
|
||||
/*******
|
||||
|
@ -126,7 +128,7 @@ typedef void (*uat_update_cb_t)(void* , const char** );
|
|||
* optional, if not given any input is considered OK and the set cb will be called
|
||||
* chk(record, ptr, len, chk_data, fld_data, &error)
|
||||
*/
|
||||
typedef gboolean (*uat_fld_chk_cb_t)(void*, const char*, unsigned, const void*, const void*, const char**);
|
||||
typedef gboolean (*uat_fld_chk_cb_t)(void*, const char*, unsigned, const void*, const void*, char**);
|
||||
|
||||
/*
|
||||
* Set Field CB
|
||||
|
@ -306,21 +308,21 @@ uat_t* uat_get_table_by_name(const char* name);
|
|||
* Some common uat_fld_chk_cbs
|
||||
*/
|
||||
WS_DLL_PUBLIC
|
||||
gboolean uat_fld_chk_str(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean uat_fld_chk_oid(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean uat_fld_chk_str(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
gboolean uat_fld_chk_oid(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
WS_DLL_PUBLIC
|
||||
gboolean uat_fld_chk_proto(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean uat_fld_chk_proto(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
WS_DLL_PUBLIC
|
||||
gboolean uat_fld_chk_num_dec(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean uat_fld_chk_num_dec(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
WS_DLL_PUBLIC
|
||||
gboolean uat_fld_chk_num_hex(void*, const char*, unsigned, const void*, const void*, const char** err);
|
||||
gboolean uat_fld_chk_num_hex(void*, const char*, unsigned, const void*, const void*, char** err);
|
||||
WS_DLL_PUBLIC
|
||||
gboolean uat_fld_chk_enum(void*, const char*, unsigned, const void*, const void*, const char**);
|
||||
gboolean uat_fld_chk_enum(void*, const char*, unsigned, const void*, const void*, char**);
|
||||
WS_DLL_PUBLIC
|
||||
gboolean uat_fld_chk_range(void*, const char*, unsigned, const void*, const void*, const char**);
|
||||
gboolean uat_fld_chk_range(void*, const char*, unsigned, const void*, const void*, char**);
|
||||
|
||||
#define CHK_STR_IS_DECL(what) \
|
||||
gboolean uat_fld_chk_str_ ## what (void*, const char*, unsigned, const void*, const void*, const char**)
|
||||
gboolean uat_fld_chk_str_ ## what (void*, const char*, unsigned, const void*, const void*, char**)
|
||||
|
||||
typedef void (*uat_cb_t)(void* uat,void* user_data);
|
||||
WS_DLL_PUBLIC
|
||||
|
@ -351,7 +353,7 @@ WS_DLL_PUBLIC
|
|||
CHK_STR_IS_DECL(isxdigit);
|
||||
|
||||
#define CHK_STR_IS_DEF(what) \
|
||||
gboolean uat_fld_chk_str_ ## what (void* UNUSED_PARAMETER(u1), const char* strptr, guint len, const void* UNUSED_PARAMETER(u2), const void* UNUSED_PARAMETER(u3), const char** err) { \
|
||||
gboolean uat_fld_chk_str_ ## what (void* UNUSED_PARAMETER(u1), const char* strptr, guint len, const void* UNUSED_PARAMETER(u2), const void* UNUSED_PARAMETER(u3), char** err) { \
|
||||
guint i; for (i=0;i<len;i++) { \
|
||||
char c = strptr[i]; \
|
||||
if (! g_ascii_ ## what(c)) { \
|
||||
|
|
|
@ -86,10 +86,11 @@ static guint parse_str_pos;
|
|||
} while(0)
|
||||
|
||||
#define SET_FIELD() \
|
||||
{ const gchar* errx; \
|
||||
{ gchar* errx; \
|
||||
if (uat->fields[colnum].cb.chk) { \
|
||||
if ( ! uat->fields[colnum].cb.chk(record, ptrx, len, uat->fields[colnum].cbdata.chk, uat->fields[colnum].fld_data, &errx) ) { \
|
||||
error = g_strdup_printf("%s:%d: %s",uat->filename,linenum,errx); \
|
||||
g_free(errx); \
|
||||
valid_record = FALSE; \
|
||||
}\
|
||||
}\
|
||||
|
@ -239,7 +240,7 @@ comment #[^\n]*\n
|
|||
|
||||
<END_OF_RECORD>{newline} {
|
||||
void* rec;
|
||||
const char* err = NULL;
|
||||
char* err = NULL;
|
||||
|
||||
linenum++;
|
||||
|
||||
|
@ -253,7 +254,7 @@ comment #[^\n]*\n
|
|||
uat->update_cb(rec,&err);
|
||||
|
||||
if (err) {
|
||||
error = (gchar*)err;
|
||||
error = err;
|
||||
yyterminate();
|
||||
}
|
||||
|
||||
|
@ -327,7 +328,7 @@ uat_load(uat_t *uat_in, char **errx)
|
|||
UAT_UPDATE(uat);
|
||||
|
||||
if (error) {
|
||||
*errx = g_strdup(error);
|
||||
*errx = error;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -366,7 +367,7 @@ uat_load_str(uat_t *uat_in, char *entry, char **err)
|
|||
UAT_UPDATE(uat);
|
||||
|
||||
if (error) {
|
||||
*err = g_strdup(error);
|
||||
*err = error;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ static void *uat_plen_record_copy_cb(void *n, const void *o, size_t siz _U_) {
|
|||
}
|
||||
|
||||
static void
|
||||
uat_plen_record_update_cb(void *r, const char **err)
|
||||
uat_plen_record_update_cb(void *r, char **err)
|
||||
{
|
||||
uat_plen_record_t *rec = (uat_plen_record_t*)r;
|
||||
if (rec->packet_range->nranges < 1) {
|
||||
|
|
|
@ -362,7 +362,7 @@ static gboolean uat_dlg_cb(GtkWidget *win _U_, gpointer user_data) {
|
|||
}
|
||||
|
||||
if (f[colnum].cb.chk) {
|
||||
if (! f[colnum].cb.chk(dd->rec, text, len, f[colnum].cbdata.chk, f[colnum].fld_data, (const char**)&err)) {
|
||||
if (! f[colnum].cb.chk(dd->rec, text, len, f[colnum].cbdata.chk, f[colnum].fld_data, &err)) {
|
||||
tmp_err = err;
|
||||
err = g_strdup_printf("error in column '%s': %s", f[colnum].title, tmp_err);
|
||||
g_free(tmp_err);
|
||||
|
@ -376,7 +376,7 @@ static gboolean uat_dlg_cb(GtkWidget *win _U_, gpointer user_data) {
|
|||
}
|
||||
|
||||
if (dd->uat->update_cb) {
|
||||
dd->uat->update_cb(dd->rec, (const char**)&err);
|
||||
dd->uat->update_cb(dd->rec, &err);
|
||||
|
||||
if (err) {
|
||||
tmp_err = err;
|
||||
|
|
|
@ -372,13 +372,14 @@ void UatDialog::enumPrefCurrentIndexChanged(int index)
|
|||
void *rec = UAT_INDEX_PTR(uat_, row);
|
||||
uat_field_t *field = &uat_->fields[cur_column_];
|
||||
const QByteArray& enum_txt = cur_combo_box_->itemText(index).toUtf8();
|
||||
const char *err = NULL;
|
||||
char *err = NULL;
|
||||
|
||||
if (field->cb.chk && field->cb.chk(rec, enum_txt.constData(), (unsigned) enum_txt.size(), field->cbdata.chk, field->fld_data, &err)) {
|
||||
field->cb.set(rec, enum_txt.constData(), (unsigned) enum_txt.size(), field->cbdata.set, field->fld_data);
|
||||
ok_button_->setEnabled(true);
|
||||
} else {
|
||||
g_free((char*)err);
|
||||
/* XXX - do something useful with the error message string */
|
||||
g_free(err);
|
||||
ok_button_->setEnabled(false);
|
||||
}
|
||||
uat_->changed = TRUE;
|
||||
|
@ -395,7 +396,7 @@ void UatDialog::stringPrefTextChanged(const QString &text)
|
|||
void *rec = UAT_INDEX_PTR(uat_, row);
|
||||
uat_field_t *field = &uat_->fields[cur_column_];
|
||||
const QByteArray& txt = text.toUtf8();
|
||||
const char *err = NULL;
|
||||
char *err = NULL;
|
||||
bool enable_ok = true;
|
||||
SyntaxLineEdit::SyntaxState ss = SyntaxLineEdit::Empty;
|
||||
|
||||
|
@ -405,7 +406,8 @@ void UatDialog::stringPrefTextChanged(const QString &text)
|
|||
saved_string_pref_ = text;
|
||||
ss = SyntaxLineEdit::Valid;
|
||||
} else {
|
||||
g_free((char*)err);
|
||||
/* XXX - do something useful with the error message string */
|
||||
g_free(err);
|
||||
enable_ok = false;
|
||||
ss = SyntaxLineEdit::Invalid;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue