summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-02-17 16:40:28 -0800
committerGuy Harris <guy@alum.mit.edu>2015-02-18 00:41:09 +0000
commit859511db14feae071cc1e6e1889ae39bfd276faa (patch)
treea6ef5501110220c93d583439f5f0257c243cde64
parent3f765b3ef94fd6044279d47d0b30b46c344e5943 (diff)
downloadwireshark-859511db14feae071cc1e6e1889ae39bfd276faa.tar.gz
Make UAT record update callbacks return a success/failure indication.
Have them return TRUE on success and FALSE on failure. Check the return value rather than whether the error string pointer is null or not. Change-Id: I800a03bcd70a6bbb7b217cf7c4800e9cdcf2189c Reviewed-on: https://code.wireshark.org/review/7222 Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--asn1/c1222/packet-c1222-template.c6
-rw-r--r--epan/dfilter/dfilter-macro.c4
-rw-r--r--epan/dissectors/packet-bootp.c7
-rw-r--r--epan/dissectors/packet-c1222.c12
-rw-r--r--epan/dissectors/packet-devicenet.c7
-rw-r--r--epan/dissectors/packet-http.c9
-rw-r--r--epan/dissectors/packet-ieee80211.c67
-rw-r--r--epan/dissectors/packet-ieee802154.c9
-rw-r--r--epan/dissectors/packet-imf.c9
-rw-r--r--epan/dissectors/packet-ipsec.c3
-rw-r--r--epan/dissectors/packet-isakmp.c25
-rw-r--r--epan/dissectors/packet-k12.c5
-rw-r--r--epan/dissectors/packet-lbmpdmtcp.c5
-rw-r--r--epan/dissectors/packet-lbmr.c5
-rw-r--r--epan/dissectors/packet-lbtrm.c5
-rw-r--r--epan/dissectors/packet-lbtru.c5
-rw-r--r--epan/dissectors/packet-lbttcp.c5
-rw-r--r--epan/dissectors/packet-pdcp-lte.c4
-rw-r--r--epan/dissectors/packet-sccp.c9
-rw-r--r--epan/dissectors/packet-sctp.c9
-rw-r--r--epan/dissectors/packet-vcdu.c5
-rw-r--r--epan/dissectors/packet-zbee-nwk-gp.c6
-rw-r--r--epan/dissectors/packet-zbee-security.c6
-rw-r--r--epan/expert.c4
-rw-r--r--epan/uat.h31
-rw-r--r--epan/uat_load.l11
-rw-r--r--plugins/stats_tree/pinfo_stats_tree.c5
-rw-r--r--ui/gtk/uat_gui.c4
28 files changed, 175 insertions, 107 deletions
diff --git a/asn1/c1222/packet-c1222-template.c b/asn1/c1222/packet-c1222-template.c
index 45f5d51c6b..9a09329976 100644
--- a/asn1/c1222/packet-c1222-template.c
+++ b/asn1/c1222/packet-c1222-template.c
@@ -722,18 +722,22 @@ encode_ber_len(guint8 *ptr, guint32 n, int maxsize)
*
* \param n points to the new record
* \param err is updated to point to an error string if needed
+ * \return FALSE if error; TRUE otherwise
*/
-static void
+static gboolean
c1222_uat_data_update_cb(void* n, char** err)
{
c1222_uat_data_t* new_rec = (c1222_uat_data_t *)n;
if (new_rec->keynum > 0xff) {
*err = g_strdup("Invalid key number; must be less than 256");
+ return FALSE;
}
if (new_rec->keylen != EAX_SIZEOF_KEY) {
*err = g_strdup("Invalid key size; must be 16 bytes");
+ return FALSE;
}
+ return TRUE;
}
/**
diff --git a/epan/dfilter/dfilter-macro.c b/epan/dfilter/dfilter-macro.c
index 729eb6cf69..443124cf94 100644
--- a/epan/dfilter/dfilter-macro.c
+++ b/epan/dfilter/dfilter-macro.c
@@ -403,7 +403,7 @@ const gchar* dfilter_macro_apply(const gchar* text, gchar** error) {
return dfilter_macro_apply_recurse(text, 0, error);
}
-static void macro_update(void* mp, gchar** error) {
+static gboolean macro_update(void* mp, gchar** error) {
dfilter_macro_t* m = (dfilter_macro_t*)mp;
GPtrArray* parts;
GArray* args_pos;
@@ -492,7 +492,7 @@ done:
DUMP_MACRO(m);
- return;
+ return TRUE;
}
static void macro_free(void* r) {
diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c
index a09ea1c10c..0c1c255a70 100644
--- a/epan/dissectors/packet-bootp.c
+++ b/epan/dissectors/packet-bootp.c
@@ -1213,11 +1213,14 @@ 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, char** err) {
+static gboolean 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))
+ if ((rec->opt == 0) || (rec->opt >=BOOTP_OPT_NUM-1)) {
*err = g_strdup_printf("Option must be between 1 and %d", BOOTP_OPT_NUM-2);
+ return FALSE;
+ }
+ return TRUE;
}
static void uat_bootp_record_free_cb(void*r) {
diff --git a/epan/dissectors/packet-c1222.c b/epan/dissectors/packet-c1222.c
index 818867dd38..e39a31e567 100644
--- a/epan/dissectors/packet-c1222.c
+++ b/epan/dissectors/packet-c1222.c
@@ -773,18 +773,22 @@ encode_ber_len(guint8 *ptr, guint32 n, int maxsize)
*
* \param n points to the new record
* \param err is updated to point to an error string if needed
+ * \return FALSE if error; TRUE otherwise
*/
-static void
+static gboolean
c1222_uat_data_update_cb(void* n, char** err)
{
c1222_uat_data_t* new_rec = (c1222_uat_data_t *)n;
if (new_rec->keynum > 0xff) {
*err = g_strdup("Invalid key number; must be less than 256");
+ return FALSE;
}
if (new_rec->keylen != EAX_SIZEOF_KEY) {
*err = g_strdup("Invalid key size; must be 16 bytes");
+ return FALSE;
}
+ return TRUE;
}
/**
@@ -1562,7 +1566,7 @@ static int dissect_MESSAGE_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_
/*--- End of included file: packet-c1222-fn.c ---*/
-#line 1044 "../../asn1/c1222/packet-c1222-template.c"
+#line 1048 "../../asn1/c1222/packet-c1222-template.c"
/**
* Dissects a a full (reassembled) C12.22 message.
@@ -1948,7 +1952,7 @@ void proto_register_c1222(void) {
"OCTET_STRING_SIZE_CONSTR002", HFILL }},
/*--- End of included file: packet-c1222-hfarr.c ---*/
-#line 1325 "../../asn1/c1222/packet-c1222-template.c"
+#line 1329 "../../asn1/c1222/packet-c1222-template.c"
};
/* List of subtrees */
@@ -1971,7 +1975,7 @@ void proto_register_c1222(void) {
&ett_c1222_Calling_authentication_value_c1221_U,
/*--- End of included file: packet-c1222-ettarr.c ---*/
-#line 1335 "../../asn1/c1222/packet-c1222-template.c"
+#line 1339 "../../asn1/c1222/packet-c1222-template.c"
};
static ei_register_info ei[] = {
diff --git a/epan/dissectors/packet-devicenet.c b/epan/dissectors/packet-devicenet.c
index 5e7974c0d7..29a1e08b0b 100644
--- a/epan/dissectors/packet-devicenet.c
+++ b/epan/dissectors/packet-devicenet.c
@@ -128,11 +128,14 @@ 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, char** err) {
+static gboolean uat_devicenet_record_update_cb(void* r, char** err) {
uat_devicenet_record_t* rec = (uat_devicenet_record_t *)r;
- if (rec->mac_id > 63)
+ if (rec->mac_id > 63) {
*err = g_strdup_printf("MAC ID must be between 0-63");
+ return FALSE;
+ }
+ return TRUE;
}
UAT_DEC_CB_DEF(uat_devicenet_records, mac_id, uat_devicenet_record_t)
diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c
index 4f4371ee8b..2f7dd5a50c 100644
--- a/epan/dissectors/packet-http.c
+++ b/epan/dissectors/packet-http.c
@@ -154,7 +154,7 @@ static guint num_header_fields = 0;
static GHashTable* header_fields_hash = NULL;
-static void
+static gboolean
header_fields_update_cb(void *r, char **err)
{
header_field_t *rec = (header_field_t *)r;
@@ -162,13 +162,13 @@ header_fields_update_cb(void *r, char **err)
if (rec->header_name == NULL) {
*err = g_strdup("Header name can't be empty");
- return;
+ return FALSE;
}
g_strstrip(rec->header_name);
if (rec->header_name[0] == 0) {
*err = g_strdup("Header name can't be empty");
- return;
+ return FALSE;
}
/* Check for invalid characters (to avoid asserting out when
@@ -177,10 +177,11 @@ header_fields_update_cb(void *r, char **err)
c = proto_check_field_name(rec->header_name);
if (c) {
*err = g_strdup_printf("Header name can't contain '%c'", c);
- return;
+ return FALSE;
}
*err = NULL;
+ return TRUE;
}
static void *
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index b0b6901b64..e1ad7dade4 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -172,7 +172,7 @@ uat_wep_key_record_copy_cb(void* n, const void* o, size_t siz _U_)
return new_key;
}
-static void
+static gboolean
uat_wep_key_record_update_cb(void* r, char** err)
{
uat_wep_key_record_t* rec = (uat_wep_key_record_t *)r;
@@ -180,37 +180,44 @@ uat_wep_key_record_update_cb(void* r, char** err)
if (rec->string == NULL) {
*err = g_strdup("Key can't be blank");
- } else {
- g_strstrip(rec->string);
- dk = parse_key_string(rec->string, rec->key);
-
- if (dk != NULL) {
- switch (dk->type) {
- case AIRPDCAP_KEY_TYPE_WEP:
- case AIRPDCAP_KEY_TYPE_WEP_40:
- case AIRPDCAP_KEY_TYPE_WEP_104:
- if (rec->key != AIRPDCAP_KEY_TYPE_WEP) {
- *err = g_strdup("Invalid key format");
- }
- break;
- case AIRPDCAP_KEY_TYPE_WPA_PWD:
- if (rec->key != AIRPDCAP_KEY_TYPE_WPA_PWD) {
- *err = g_strdup("Invalid key format");
- }
- break;
- case AIRPDCAP_KEY_TYPE_WPA_PSK:
- if (rec->key != AIRPDCAP_KEY_TYPE_WPA_PSK) {
- *err = g_strdup("Invalid key format");
- }
- break;
- default:
- *err = g_strdup("Invalid key format");
- break;
- }
- } else {
- *err = g_strdup("Invalid key format");
+ return FALSE;
+ }
+
+ g_strstrip(rec->string);
+ dk = parse_key_string(rec->string, rec->key);
+
+ if (dk != NULL) {
+ switch (dk->type) {
+ case AIRPDCAP_KEY_TYPE_WEP:
+ case AIRPDCAP_KEY_TYPE_WEP_40:
+ case AIRPDCAP_KEY_TYPE_WEP_104:
+ if (rec->key != AIRPDCAP_KEY_TYPE_WEP) {
+ *err = g_strdup("Invalid key format");
+ return FALSE;
+ }
+ break;
+ case AIRPDCAP_KEY_TYPE_WPA_PWD:
+ if (rec->key != AIRPDCAP_KEY_TYPE_WPA_PWD) {
+ *err = g_strdup("Invalid key format");
+ return FALSE;
+ }
+ break;
+ case AIRPDCAP_KEY_TYPE_WPA_PSK:
+ if (rec->key != AIRPDCAP_KEY_TYPE_WPA_PSK) {
+ *err = g_strdup("Invalid key format");
+ return FALSE;
+ }
+ break;
+ default:
+ *err = g_strdup("Invalid key format");
+ return FALSE;
+ break;
}
+ } else {
+ *err = g_strdup("Invalid key format");
+ return FALSE;
}
+ return TRUE;
}
static void
diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c
index 58a458fb57..2467bc1651 100644
--- a/epan/dissectors/packet-ieee802154.c
+++ b/epan/dissectors/packet-ieee802154.c
@@ -128,25 +128,26 @@ static static_addr_t *static_addrs = NULL;
static guint num_static_addrs = 0;
/* Sanity-checks a UAT record. */
-static void
+static gboolean
addr_uat_update_cb(void *r, char **err)
{
static_addr_t *map = (static_addr_t *)r;
/* Ensure a valid short address */
if (map->addr16 >= IEEE802154_NO_ADDR16) {
*err = g_strdup("Invalid short address");
- return;
+ return FALSE;
}
/* Ensure a valid PAN identifier. */
if (map->pan >= IEEE802154_BCAST_PAN) {
*err = g_strdup("Invalid PAN identifier");
- return;
+ return FALSE;
}
/* Ensure a valid EUI-64 length */
if (map->eui64_len != sizeof(guint64)) {
*err = g_strdup("Invalid EUI-64 length");
- return;
+ return FALSE;
}
+ return TRUE;
} /* ieee802154_addr_uat_update_cb */
/* Field callbacks. */
diff --git a/epan/dissectors/packet-imf.c b/epan/dissectors/packet-imf.c
index dae55e8e06..75d367b72c 100644
--- a/epan/dissectors/packet-imf.c
+++ b/epan/dissectors/packet-imf.c
@@ -275,7 +275,7 @@ static guint num_header_fields = 0;
static GHashTable *custom_field_table = NULL;
-static void
+static gboolean
header_fields_update_cb(void *r, char **err)
{
header_field_t *rec = (header_field_t *)r;
@@ -283,13 +283,13 @@ header_fields_update_cb(void *r, char **err)
if (rec->header_name == NULL) {
*err = g_strdup("Header name can't be empty");
- return;
+ return FALSE;
}
g_strstrip(rec->header_name);
if (rec->header_name[0] == 0) {
*err = g_strdup("Header name can't be empty");
- return;
+ return FALSE;
}
/* Check for invalid characters (to avoid asserting out when
@@ -298,10 +298,11 @@ header_fields_update_cb(void *r, char **err)
c = proto_check_field_name(rec->header_name);
if (c) {
*err = g_strdup_printf("Header name can't contain '%c'", c);
- return;
+ return FALSE;
}
*err = NULL;
+ return TRUE;
}
static void *
diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c
index ffba2db38c..a21297a99d 100644
--- a/epan/dissectors/packet-ipsec.c
+++ b/epan/dissectors/packet-ipsec.c
@@ -354,7 +354,7 @@ compute_ascii_key(gchar **ascii_key, const gchar *key)
}
-static void uat_esp_sa_record_update_cb(void* r, char** err _U_) {
+static gboolean 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 */
@@ -374,6 +374,7 @@ static void uat_esp_sa_record_update_cb(void* r, char** err _U_) {
rec->authentication_key_length = 0;
rec->authentication_key = NULL;
}
+ return TRUE;
}
static void* uat_esp_sa_record_copy_cb(void* n, const void* o, size_t siz _U_) {
diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c
index 31a285c607..b27a2ed037 100644
--- a/epan/dissectors/packet-isakmp.c
+++ b/epan/dissectors/packet-isakmp.c
@@ -4994,24 +4994,25 @@ 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, char** err) {
+static gboolean 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) {
*err = g_strdup_printf("Length of Initiator's COOKIE must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
- return;
+ return FALSE;
}
if (ud->key_len == 0) {
*err = g_strdup_printf("Must have Encryption key.");
- return;
+ return FALSE;
}
if (ud->key_len > MAX_KEY_SIZE) {
*err = g_strdup_printf("Length of Encryption key limited to %d octets (%d hex characters).", MAX_KEY_SIZE, MAX_KEY_SIZE * 2);
- return;
+ return FALSE;
}
+ return TRUE;
}
UAT_BUFFER_CB_DEF(ikev2_users, spii, ikev2_uat_data_t, key.spii, key.spii_len)
@@ -5023,17 +5024,17 @@ 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, char** err) {
+static gboolean 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) {
*err = g_strdup_printf("Length of Initiator's SPI must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
- return;
+ return FALSE;
}
if (ud->key.spir_len != COOKIE_SIZE) {
*err = g_strdup_printf("Length of Responder's SPI must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
- return;
+ return FALSE;
}
if ((ud->encr_spec = ikev2_decrypt_find_encr_spec(ud->encr_alg)) == NULL) {
@@ -5047,26 +5048,28 @@ static void ikev2_uat_data_update_cb(void* p, char** err) {
if (ud->sk_ei_len != ud->encr_spec->key_len) {
*err = g_strdup_printf("Length of SK_ei (%u octets) does not match the key length (%u octets) of the selected encryption algorithm.",
ud->sk_ei_len, ud->encr_spec->key_len);
- return;
+ return FALSE;
}
if (ud->sk_er_len != ud->encr_spec->key_len) {
*err = g_strdup_printf("Length of SK_er (%u octets) does not match the key length (%u octets) of the selected encryption algorithm.",
ud->sk_er_len, ud->encr_spec->key_len);
- return;
+ return FALSE;
}
if (ud->sk_ai_len != ud->auth_spec->key_len) {
*err = g_strdup_printf("Length of SK_ai (%u octets) does not match the key length (%u octets) of the selected integrity algorithm.",
ud->sk_ai_len, ud->auth_spec->key_len);
- return;
+ return FALSE;
}
if (ud->sk_ar_len != ud->auth_spec->key_len) {
*err = g_strdup_printf("Length of SK_ar (%u octets) does not match the key length (%u octets) of the selected integrity algorithm.",
ud->sk_ar_len, ud->auth_spec->key_len);
- return;
+ return FALSE;
}
+
+ return TRUE;
}
#endif /* HAVE_LIBGCRYPT */
diff --git a/epan/dissectors/packet-k12.c b/epan/dissectors/packet-k12.c
index 58b8aac9ae..792c1e7b38 100644
--- a/epan/dissectors/packet-k12.c
+++ b/epan/dissectors/packet-k12.c
@@ -296,7 +296,7 @@ dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree)
call_dissector(sub_handle, tvb, pinfo, tree);
}
-static void
+static gboolean
k12_update_cb(void* r, char** err)
{
k12_handles_t* h = (k12_handles_t *)r;
@@ -316,12 +316,13 @@ k12_update_cb(void* r, char** err)
h->handles[i] = data_handle;
g_strfreev(protos);
*err = g_strdup_printf("Could not find dissector for: '%s'",protos[i]);
- return;
+ return FALSE;
}
}
g_strfreev(protos);
*err = NULL;
+ return TRUE;
}
static void*
diff --git a/epan/dissectors/packet-lbmpdmtcp.c b/epan/dissectors/packet-lbmpdmtcp.c
index ae93f69499..94f3172845 100644
--- a/epan/dissectors/packet-lbmpdmtcp.c
+++ b/epan/dissectors/packet-lbmpdmtcp.c
@@ -153,13 +153,14 @@ static uat_field_t lbmpdm_tcp_tag_array[] =
/*----------------------------------------------------------------------------*/
/* UAT callback functions. */
/*----------------------------------------------------------------------------*/
-static void lbmpdm_tcp_tag_update_cb(void * record, char * * error_string)
+static gboolean lbmpdm_tcp_tag_update_cb(void * record, char * * error_string)
{
lbmpdm_tcp_tag_entry_t * tag = (lbmpdm_tcp_tag_entry_t *)record;
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
else
{
@@ -167,8 +168,10 @@ static void lbmpdm_tcp_tag_update_cb(void * record, char * * error_string)
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
}
+ return TRUE;
}
static void * lbmpdm_tcp_tag_copy_cb(void * destination, const void * source, size_t length _U_)
diff --git a/epan/dissectors/packet-lbmr.c b/epan/dissectors/packet-lbmr.c
index 5678bfb191..092f2222f2 100644
--- a/epan/dissectors/packet-lbmr.c
+++ b/epan/dissectors/packet-lbmr.c
@@ -1968,13 +1968,14 @@ static uat_field_t lbmr_tag_array[] =
/*----------------------------------------------------------------------------*/
/* UAT callback functions. */
/*----------------------------------------------------------------------------*/
-static void lbmr_tag_update_cb(void * record, char * * error_string)
+static gboolean lbmr_tag_update_cb(void * record, char * * error_string)
{
lbmr_tag_entry_t * tag = (lbmr_tag_entry_t *)record;
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
else
{
@@ -1982,8 +1983,10 @@ static void lbmr_tag_update_cb(void * record, char * * error_string)
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
}
+ return TRUE;
}
static void * lbmr_tag_copy_cb(void * destination, const void * source, size_t length _U_)
diff --git a/epan/dissectors/packet-lbtrm.c b/epan/dissectors/packet-lbtrm.c
index a8c73b576e..933251299f 100644
--- a/epan/dissectors/packet-lbtrm.c
+++ b/epan/dissectors/packet-lbtrm.c
@@ -653,13 +653,14 @@ static uat_field_t lbtrm_tag_array[] =
/*----------------------------------------------------------------------------*/
/* UAT callback functions. */
/*----------------------------------------------------------------------------*/
-static void lbtrm_tag_update_cb(void * record, char * * error_string)
+static gboolean lbtrm_tag_update_cb(void * record, char * * error_string)
{
lbtrm_tag_entry_t * tag = (lbtrm_tag_entry_t *)record;
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
else
{
@@ -667,8 +668,10 @@ static void lbtrm_tag_update_cb(void * record, char * * error_string)
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
}
+ return TRUE;
}
static void * lbtrm_tag_copy_cb(void * destination, const void * source, size_t length _U_)
diff --git a/epan/dissectors/packet-lbtru.c b/epan/dissectors/packet-lbtru.c
index 4051ed2814..ff6640b796 100644
--- a/epan/dissectors/packet-lbtru.c
+++ b/epan/dissectors/packet-lbtru.c
@@ -695,13 +695,14 @@ static uat_field_t lbtru_tag_array[] =
/*----------------------------------------------------------------------------*/
/* UAT callback functions. */
/*----------------------------------------------------------------------------*/
-static void lbtru_tag_update_cb(void * record, char * * error_string)
+static gboolean lbtru_tag_update_cb(void * record, char * * error_string)
{
lbtru_tag_entry_t * tag = (lbtru_tag_entry_t *)record;
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
else
{
@@ -709,8 +710,10 @@ static void lbtru_tag_update_cb(void * record, char * * error_string)
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
}
+ return TRUE;
}
static void * lbtru_tag_copy_cb(void * destination, const void * source, size_t length _U_)
diff --git a/epan/dissectors/packet-lbttcp.c b/epan/dissectors/packet-lbttcp.c
index bae06e9acb..6ba8a0532b 100644
--- a/epan/dissectors/packet-lbttcp.c
+++ b/epan/dissectors/packet-lbttcp.c
@@ -326,13 +326,14 @@ static uat_field_t lbttcp_tag_array[] =
/*----------------------------------------------------------------------------*/
/* UAT callback functions. */
/*----------------------------------------------------------------------------*/
-static void lbttcp_tag_update_cb(void * record, char * * error_string)
+static gboolean lbttcp_tag_update_cb(void * record, char * * error_string)
{
lbttcp_tag_entry_t * tag = (lbttcp_tag_entry_t *)record;
if (tag->name == NULL)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
else
{
@@ -340,8 +341,10 @@ static void lbttcp_tag_update_cb(void * record, char * * error_string)
if (tag->name[0] == 0)
{
*error_string = g_strdup_printf("Tag name can't be empty");
+ return FALSE;
}
}
+ return TRUE;
}
static void * lbttcp_tag_copy_cb(void * destination, const void * source, size_t length _U_)
diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c
index c6f15d1988..162011bce2 100644
--- a/epan/dissectors/packet-pdcp-lte.c
+++ b/epan/dissectors/packet-pdcp-lte.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, char** error _U_) {
+static gboolean 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 */
@@ -259,6 +259,8 @@ static void uat_ue_keys_record_update_cb(void* record, char** error _U_) {
/* Check and convert Integrity key */
update_key_from_string(rec->rrcIntegrityKeyString, rec->rrcIntegrityBinaryKey, &rec->rrcIntegrityKeyOK);
+
+ return TRUE;
}
/* Free heap parts of record */
diff --git a/epan/dissectors/packet-sccp.c b/epan/dissectors/packet-sccp.c
index 64604accd8..a23011d75f 100644
--- a/epan/dissectors/packet-sccp.c
+++ b/epan/dissectors/packet-sccp.c
@@ -3419,7 +3419,7 @@ static struct _sccp_ul {
{0, FALSE, NULL}
};
-static void
+static gboolean
sccp_users_update_cb(void *r, char **err)
{
sccp_user_t *u = (sccp_user_t *)r;
@@ -3429,24 +3429,25 @@ sccp_users_update_cb(void *r, char **err)
empty = range_empty();
if (ranges_are_equal(u->called_pc, empty)) {
*err = g_strdup("Must specify a PC");
- return;
+ return FALSE;
}
if (ranges_are_equal(u->called_ssn, empty)) {
*err = g_strdup("Must specify an SSN");
- return;
+ return FALSE;
}
for (c=user_list; c->handlep; c++) {
if (c->id == u->user) {
u->uses_tcap = c->uses_tcap;
u->handlep = c->handlep;
- return;
+ return TRUE;
}
}
u->uses_tcap = FALSE;
u->handlep = &data_handle;
+ return TRUE;
}
static void *
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index 48962aa045..e35dcbf144 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -538,20 +538,20 @@ sctp_chunk_type_free_cb(void* r)
if (rec->type_name) g_free(rec->type_name);
}
-static void
+static gboolean
sctp_chunk_type_update_cb(void *r, char **err)
{
type_field_t *rec = (type_field_t *)r;
char c;
if (rec->type_name == NULL) {
*err = g_strdup("Header name can't be empty");
- return;
+ return FALSE;
}
g_strstrip(rec->type_name);
if (rec->type_name[0] == 0) {
*err = g_strdup("Header name can't be empty");
- return;
+ return FALSE;
}
/* Check for invalid characters (to avoid asserting out when
@@ -560,10 +560,11 @@ sctp_chunk_type_update_cb(void *r, char **err)
c = proto_check_field_name(rec->type_name);
if (c) {
*err = g_strdup_printf("Header name can't contain '%c'", c);
- return;
+ return FALSE;
}
*err = NULL;
+ return TRUE;
}
static struct _sctp_info sctp_info;
diff --git a/epan/dissectors/packet-vcdu.c b/epan/dissectors/packet-vcdu.c
index 98b7e9520f..f93394be8e 100644
--- a/epan/dissectors/packet-vcdu.c
+++ b/epan/dissectors/packet-vcdu.c
@@ -182,14 +182,15 @@ static guint num_channels_uat = 0;
UAT_DEC_CB_DEF(uat_bitchannels, channel, uat_channel_t)
-static void
+static gboolean
vcdu_uat_data_update_cb(void *p, char **err) {
uat_channel_t *ud = (uat_channel_t *)p;
if (ud->channel >= 64) {
*err = g_strdup("Channel must be between 0-63.");
- return;
+ return FALSE;
}
+ return TRUE;
}
static void
diff --git a/epan/dissectors/packet-zbee-nwk-gp.c b/epan/dissectors/packet-zbee-nwk-gp.c
index cd8f89532d..3b8e2e9e84 100644
--- a/epan/dissectors/packet-zbee-nwk-gp.c
+++ b/epan/dissectors/packet-zbee-nwk-gp.c
@@ -618,13 +618,14 @@ zbee_gp_security_parse_key(const gchar *key_str, guint8 *key_buf, gboolean byte_
}
/* UAT record update callback. */
-static void
+static gboolean
uat_key_record_update_cb(void *r, char **err)
{
uat_key_record_t *rec = (uat_key_record_t *)r;
if (rec->string == NULL) {
*err = g_strdup_printf("Key can't be blank.");
+ return FALSE;
} else {
g_strstrip(rec->string);
if (rec->string[0] != 0) {
@@ -632,11 +633,14 @@ uat_key_record_update_cb(void *r, char **err)
if (!zbee_gp_security_parse_key(rec->string, rec->key, rec->byte_order)) {
*err = g_strdup_printf("Expecting %d hexadecimal bytes or a %d character double-quoted string",
ZBEE_SEC_CONST_KEYSIZE, ZBEE_SEC_CONST_KEYSIZE);
+ return FALSE;
}
} else {
*err = g_strdup_printf("Key can't be blank.");
+ return FALSE;
}
}
+ return TRUE;
}
/*FUNCTION:------------------------------------------------------
diff --git a/epan/dissectors/packet-zbee-security.c b/epan/dissectors/packet-zbee-security.c
index c2312a1b1f..51590f01ed 100644
--- a/epan/dissectors/packet-zbee-security.c
+++ b/epan/dissectors/packet-zbee-security.c
@@ -159,12 +159,13 @@ 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, char** err) {
+static gboolean 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];
if (rec->string == NULL) {
*err = g_strdup("Key can't be blank");
+ return FALSE;
} else {
g_strstrip(rec->string);
@@ -173,11 +174,14 @@ static void uat_key_record_update_cb(void* r, char** err) {
if ( !zbee_security_parse_key(rec->string, key, rec->byte_order) ) {
*err = g_strdup_printf("Expecting %d hexadecimal bytes or\n"
"a %d character double-quoted string", ZBEE_SEC_CONST_KEYSIZE, ZBEE_SEC_CONST_KEYSIZE);
+ return FALSE;
}
} else {
*err = g_strdup("Key can't be blank");
+ return FALSE;
}
}
+ return TRUE;
}
static void uat_key_record_free_cb(void*r) {
diff --git a/epan/expert.c b/epan/expert.c
index da47c135c7..a5d942a476 100644
--- a/epan/expert.c
+++ b/epan/expert.c
@@ -121,13 +121,15 @@ 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, char **err)
+static gboolean uat_expert_update_cb(void *r, char **err)
{
expert_level_entry_t *rec = (expert_level_entry_t *)r;
if (expert_registrar_get_byname(rec->field) == NULL) {
*err = g_strdup_printf("Expert Info field doesn't exist");
+ return FALSE;
}
+ return TRUE;
}
static void *uat_expert_copy_cb(void *n, const void *o, size_t siz _U_)
diff --git a/epan/uat.h b/epan/uat.h
index 8e9f56643f..c0f49a4b4f 100644
--- a/epan/uat.h
+++ b/epan/uat.h
@@ -84,33 +84,36 @@ typedef void (*uat_post_update_cb_t)(void);
/*
* Copy CB
+ * copy(dest,orig,len)
+ *
* used to copy a record
* optional, memcpy will be used if not given
- * copy(dest,orig,len)
*/
typedef void* (*uat_copy_cb_t)(void*, const void*, size_t);
/*
- *
* Free CB
+ * free(record)
*
* destroy a record's child data
* (do not free the container, it will be handled by uat)
* it is optional, no child data will be freed if no present
- * free(record)
*/
typedef void (*uat_free_cb_t)(void*);
/*
* Update CB
+ * update(record,&error)
*
* to be called after any record fields had been updated
* optional, record will be updated always if not given
- * update(record,&error)
+ * it will return TRUE if OK or else
+ * it will return FALSE and set *error to inform the user on what's
+ * wrong with the given input
* The error string must be allocated with g_malloc() or
* a routine that calls it.
*/
-typedef void (*uat_update_cb_t)(void* , char** );
+typedef gboolean (*uat_update_cb_t)(void *, char**);
/*******
@@ -119,31 +122,39 @@ typedef void (*uat_update_cb_t)(void* , char** );
********/
/*
+ * Check CB
+ * chk(record, ptr, len, chk_data, fld_data, &error)
+ *
* given an input string (ptr, len) checks if the value is OK for a field in the record.
* it will return TRUE if OK or else
- * it will return FALSE and may set *error to inform the user on what's
+ * it will return FALSE and set *error to inform the user on what's
* wrong with the given input
+ * The error string must be allocated with g_malloc() or
+ * a routine that calls it.
* 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*, char**);
/*
* Set Field CB
+ * set(record, ptr, len, set_data, fld_data)
*
* given an input string (ptr, len) sets the value of a field in the record,
* it will return TRUE if OK or else
- * it will return FALSE and may set *error to inform the user on what's
+ * it will return FALSE and set *error to inform the user on what's
* wrong with the given input
+ * The error string must be allocated with g_malloc() or
+ * a routine that calls it.
* it is mandatory
- * set(record, ptr, len, set_data, fld_data)
*/
typedef void (*uat_fld_set_cb_t)(void*, const char*, unsigned, const void*, const void*);
/*
+ * Convert-to-string CB
+ * tostr(record, &out_ptr, &out_len, tostr_data, fld_data)
+ *
* given a record returns a string representation of the field
* mandatory
- * tostr(record, &out_ptr, &out_len, tostr_data, fld_data)
*/
typedef void (*uat_fld_tostr_cb_t)(void*, const char**, unsigned*, const void*, const void*);
diff --git a/epan/uat_load.l b/epan/uat_load.l
index b9e8ee9a23..43452fc701 100644
--- a/epan/uat_load.l
+++ b/epan/uat_load.l
@@ -249,12 +249,11 @@ comment #[^\n]*\n
rec = uat_add_record(uat, record, valid_record);
- if ((uat->update_cb) && (rec != NULL))
- uat->update_cb(rec,&err);
-
- if (err) {
- error = err;
- yyterminate();
+ if ((uat->update_cb) && (rec != NULL)) {
+ if (!uat->update_cb(rec,&err)) {
+ error = err;
+ yyterminate();
+ }
}
valid_record = TRUE;
diff --git a/plugins/stats_tree/pinfo_stats_tree.c b/plugins/stats_tree/pinfo_stats_tree.c
index b54a5f7091..42c461e296 100644
--- a/plugins/stats_tree/pinfo_stats_tree.c
+++ b/plugins/stats_tree/pinfo_stats_tree.c
@@ -65,16 +65,17 @@ static void *uat_plen_record_copy_cb(void *n, const void *o, size_t siz _U_) {
return n;
}
-static void
+static gboolean
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) {
*err = g_strdup("Invalid range string");
- return;
+ return FALSE;
}
*err = NULL;
+ return TRUE;
}
static void uat_plen_record_free_cb(void*r) {
diff --git a/ui/gtk/uat_gui.c b/ui/gtk/uat_gui.c
index 1b30680b76..e4de9ffe7d 100644
--- a/ui/gtk/uat_gui.c
+++ b/ui/gtk/uat_gui.c
@@ -375,9 +375,7 @@ static gboolean uat_dlg_cb(GtkWidget *win _U_, gpointer user_data) {
}
if (dd->uat->update_cb) {
- dd->uat->update_cb(dd->rec, &err);
-
- if (err) {
+ if (!dd->uat->update_cb(dd->rec, &err)) {
tmp_err = err;
err = g_strdup_printf("error updating record: %s", tmp_err);
g_free(tmp_err);