{ FALSE, FALSE, 0x0, TRUE, NULL, NULL }
};
-static void
+static void
clear_canon(void)
{
const TOP_ELEMENT_CONTROL *t = canonifyTable;
c1222_uat_data_t* new_rec = (c1222_uat_data_t *)n;
if (new_rec->keynum > 0xff) {
- *err = "Invalid key number; must be less than 256";
+ *err = g_strdup("Invalid key number; must be less than 256");
}
if (new_rec->keylen != EAX_SIZEOF_KEY) {
- *err = "Invalid key size; must be 16 bytes";
+ *err = g_strdup("Invalid key size; must be 16 bytes");
}
}
char c;
if (rec->attribute_type == NULL) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't be empty");
+ *err = g_strdup("Attribute type can't be empty");
return;
}
g_strstrip(rec->attribute_type);
if (rec->attribute_type[0] == 0) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't be empty");
+ *err = g_strdup("Attribute type can't be empty");
return;
}
*/
c = proto_check_field_name(rec->attribute_type);
if (c) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't contain '%c'", c);
+ *err = g_strdup_printf("Attribute type can't contain '%c'", c);
return;
}
snmp_users_update_cb(void* p _U_, const char** err)
{
snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
- emem_strbuf_t* es = ep_strbuf_new("");
+ GString* es = g_string_new("");
unsigned int i;
*err = NULL;
return;
if (! ue->user.userName.len)
- ep_strbuf_append_printf(es,"no userName\n");
+ g_string_append_printf(es,"no userName\n");
for (i=0; i<num_ueas-1; i++) {
snmp_ue_assoc_t* u = &(ueas[i]);
/* RFC 3411 section 5 */
if ((u->engine.len > 0) && (u->engine.len < 5 || u->engine.len > 32)) {
- ep_strbuf_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", u->engine.len);
+ g_string_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", u->engine.len);
}
if (u->engine.len > 0 && memcmp( u->engine.data, ue->engine.data, u->engine.len ) == 0) {
if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
/* XXX: make a string for the engineId */
- ep_strbuf_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
+ g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
}
}
if (u->engine.len == 0) {
if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
- ep_strbuf_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
+ g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
}
}
}
}
if (es->len) {
- es = ep_strbuf_truncate(es,es->len-1);
- *err = ep_strdup(es->str);
+ es = g_string_truncate(es,es->len-1);
+ *err = g_string_free(es, FALSE);
}
return;
if (m == &(macros[i])) continue;
if ( g_str_equal(m->name,macros[i].name) ) {
- *error = ep_strdup_printf("macro '%s' exists already", m->name);
+ *error = g_strdup_printf("macro '%s' exists already", m->name);
m->usable = FALSE;
return;
}
uat_bootp_record_t* rec = (uat_bootp_record_t *)r;
if ((rec->opt == 0) || (rec->opt >=BOOTP_OPT_NUM-1))
- *err = ep_strdup_printf("Option must be between 1 and %d", BOOTP_OPT_NUM-2);
+ *err = g_strdup_printf("Option must be between 1 and %d", BOOTP_OPT_NUM-2);
}
static void uat_bootp_record_free_cb(void*r) {
/* Now apply the custom options */
for (i = 0; i < num_bootp_records_uat; i++)
{
- bootp_opt[uat_bootp_records[i].opt].text = se_strdup(uat_bootp_records[i].text);
+ bootp_opt[uat_bootp_records[i].opt].text = wmem_strdup(wmem_file_scope(), uat_bootp_records[i].text);
bootp_opt[uat_bootp_records[i].opt].ftype = uat_bootp_records[i].ftype;
bootp_opt[uat_bootp_records[i].opt].phf = NULL;
}
{ FALSE, FALSE, 0x0, TRUE, NULL, NULL }
};
-static void
+static void
clear_canon(void)
{
const TOP_ELEMENT_CONTROL *t = canonifyTable;
c1222_uat_data_t* new_rec = (c1222_uat_data_t *)n;
if (new_rec->keynum > 0xff) {
- *err = "Invalid key number; must be less than 256";
+ *err = g_strdup("Invalid key number; must be less than 256");
}
if (new_rec->keylen != EAX_SIZEOF_KEY) {
- *err = "Invalid key size; must be 16 bytes";
+ *err = g_strdup("Invalid key size; must be 16 bytes");
}
}
char c;
if (rec->header_name == NULL) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Header name can't be empty");
+ *err = g_strdup("Header name can't be empty");
return;
}
g_strstrip(rec->header_name);
if (rec->header_name[0] == 0) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Header name can't be empty");
+ *err = g_strdup("Header name can't be empty");
return;
}
*/
c = proto_check_field_name(rec->header_name);
if (c) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Header name can't contain '%c'", c);
+ *err = g_strdup_printf("Header name can't contain '%c'", c);
return;
}
decryption_key_t* dk;
if (rec->string == NULL) {
- *err = ep_strdup_printf("Key can't be blank");
+ *err = g_strdup("Key can't be blank");
} else {
g_strstrip(rec->string);
dk = parse_key_string(rec->string, rec->key);
case AIRPDCAP_KEY_TYPE_WEP_40:
case AIRPDCAP_KEY_TYPE_WEP_104:
if (rec->key != AIRPDCAP_KEY_TYPE_WEP) {
- *err = ep_strdup_printf("Invalid key format");
+ *err = g_strdup("Invalid key format");
}
break;
case AIRPDCAP_KEY_TYPE_WPA_PWD:
if (rec->key != AIRPDCAP_KEY_TYPE_WPA_PWD) {
- *err = ep_strdup_printf("Invalid key format");
+ *err = g_strdup("Invalid key format");
}
break;
case AIRPDCAP_KEY_TYPE_WPA_PSK:
if (rec->key != AIRPDCAP_KEY_TYPE_WPA_PSK) {
- *err = ep_strdup_printf("Invalid key format");
+ *err = g_strdup("Invalid key format");
}
break;
default:
- *err = ep_strdup_printf("Invalid key format");
+ *err = g_strdup("Invalid key format");
break;
}
} else {
- *err = ep_strdup_printf("Invalid key format");
+ *err = g_strdup("Invalid key format");
}
}
}
static_addr_t *map = (static_addr_t *)r;
/* Ensure a valid short address */
if (map->addr16 >= IEEE802154_NO_ADDR16) {
- *err = "Invalid short address";
+ *err = g_strdup("Invalid short address");
+ return;
}
/* Ensure a valid PAN identifier. */
if (map->pan >= IEEE802154_BCAST_PAN) {
- *err = "Invalid PAN identifier";
+ *err = g_strdup("Invalid PAN identifier");
+ return;
}
/* Ensure a valid EUI-64 length */
if (map->eui64_len != sizeof(guint64)) {
- *err = "Invalid EUI-64 length";
+ *err = g_strdup("Invalid EUI-64 length");
+ return;
}
} /* ieee802154_addr_uat_update_cb */
char c;
if (rec->header_name == NULL) {
- *err = ep_strdup_printf("Header name can't be empty");
+ *err = g_strdup("Header name can't be empty");
return;
}
g_strstrip(rec->header_name);
if (rec->header_name[0] == 0) {
- *err = ep_strdup_printf("Header name can't be empty");
+ *err = g_strdup("Header name can't be empty");
return;
}
*/
c = proto_check_field_name(rec->header_name);
if (c) {
- *err = ep_strdup_printf("Header name can't contain '%c'", c);
+ *err = g_strdup_printf("Header name can't contain '%c'", c);
return;
}
ikev1_uat_data_key_t *ud = (ikev1_uat_data_key_t *)p;
if (ud->icookie_len != COOKIE_SIZE) {
- *err = ep_strdup_printf("Length of Initiator's COOKIE must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
+ *err = g_strdup_printf("Length of Initiator's COOKIE must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
return;
}
if (ud->key_len == 0) {
- *err = ep_strdup_printf("Must have Encryption key.");
+ *err = g_strdup_printf("Must have Encryption key.");
return;
}
if (ud->key_len > MAX_KEY_SIZE) {
- *err = ep_strdup_printf("Length of Encryption key limited to %d octets (%d hex characters).", MAX_KEY_SIZE, MAX_KEY_SIZE * 2);
+ *err = g_strdup_printf("Length of Encryption key limited to %d octets (%d hex characters).", MAX_KEY_SIZE, MAX_KEY_SIZE * 2);
return;
}
ikev2_uat_data_t *ud = (ikev2_uat_data_t *)p;
if (ud->key.spii_len != COOKIE_SIZE) {
- *err = ep_strdup_printf("Length of Initiator's SPI must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
+ *err = g_strdup_printf("Length of Initiator's SPI must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
return;
}
if (ud->key.spir_len != COOKIE_SIZE) {
- *err = ep_strdup_printf("Length of Responder's SPI must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
+ *err = g_strdup_printf("Length of Responder's SPI must be %d octets (%d hex characters).", COOKIE_SIZE, COOKIE_SIZE * 2);
return;
}
}
if (ud->sk_ei_len != ud->encr_spec->key_len) {
- *err = ep_strdup_printf("Length of SK_ei (%u octets) does not match the key length (%u octets) of the selected encryption algorithm.",
+ *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;
}
if (ud->sk_er_len != ud->encr_spec->key_len) {
- *err = ep_strdup_printf("Length of SK_er (%u octets) does not match the key length (%u octets) of the selected encryption algorithm.",
+ *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;
}
if (ud->sk_ai_len != ud->auth_spec->key_len) {
- *err = ep_strdup_printf("Length of SK_ai (%u octets) does not match the key length (%u octets) of the selected integrity algorithm.",
+ *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;
}
if (ud->sk_ar_len != ud->auth_spec->key_len) {
- *err = ep_strdup_printf("Length of SK_ar (%u octets) does not match the key length (%u octets) of the selected integrity algorithm.",
+ *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;
}
gchar** protos;
guint num_protos, i;
- protos = ep_strsplit(h->protos,":",0);
+ protos = g_strsplit(h->protos,":",0);
for (num_protos = 0; protos[num_protos]; num_protos++)
g_strstrip(protos[num_protos]);
for (i = 0; i < num_protos; i++) {
if ( ! (h->handles[i] = find_dissector(protos[i])) ) {
h->handles[i] = data_handle;
- *err = ep_strdup_printf("Could not find dissector for: '%s'",protos[i]);
+ g_strfreev(protos);
+ *err = g_strdup_printf("Could not find dissector for: '%s'",protos[i]);
return;
}
}
+ g_strfreev(protos);
*err = NULL;
}
char c;
if (rec->attribute_type == NULL) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't be empty");
+ *err = g_strdup("Attribute type can't be empty");
return;
}
g_strstrip(rec->attribute_type);
if (rec->attribute_type[0] == 0) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't be empty");
+ *err = g_strdup("Attribute type can't be empty");
return;
}
*/
c = proto_check_field_name(rec->attribute_type);
if (c) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Attribute type can't contain '%c'", c);
+ *err = g_strdup_printf("Attribute type can't contain '%c'", c);
return;
}
empty = range_empty();
if (ranges_are_equal(u->called_pc, empty)) {
- *err = ep_strdup_printf("Must specify a PC");
+ *err = g_strdup("Must specify a PC");
return;
}
if (ranges_are_equal(u->called_ssn, empty)) {
- *err = ep_strdup_printf("Must specify an SSN");
+ *err = g_strdup("Must specify an SSN");
return;
}
snmp_users_update_cb(void* p _U_, const char** err)
{
snmp_ue_assoc_t* ue = (snmp_ue_assoc_t*)p;
- emem_strbuf_t* es = ep_strbuf_new("");
+ GString* es = g_string_new("");
unsigned int i;
*err = NULL;
return;
if (! ue->user.userName.len)
- ep_strbuf_append_printf(es,"no userName\n");
+ g_string_append_printf(es,"no userName\n");
for (i=0; i<num_ueas-1; i++) {
snmp_ue_assoc_t* u = &(ueas[i]);
/* RFC 3411 section 5 */
if ((u->engine.len > 0) && (u->engine.len < 5 || u->engine.len > 32)) {
- ep_strbuf_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", u->engine.len);
+ g_string_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", u->engine.len);
}
if (u->engine.len > 0 && memcmp( u->engine.data, ue->engine.data, u->engine.len ) == 0) {
if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
/* XXX: make a string for the engineId */
- ep_strbuf_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
+ g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
}
}
if (u->engine.len == 0) {
if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
- ep_strbuf_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
+ g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
}
}
}
}
if (es->len) {
- es = ep_strbuf_truncate(es,es->len-1);
- *err = ep_strdup(es->str);
+ es = g_string_truncate(es,es->len-1);
+ *err = g_string_free(es, FALSE);
}
return;
g_free(h->password);
}
-static void
-ssldecrypt_update_cb(void *r _U_, const char **err)
-{
- if (err)
- *err = NULL;
- return;
-}
-
static void*
ssldecrypt_copy_cb(void *dest, const void *orig, size_t len _U_)
{
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* Help section (currently a wiki page) */
ssldecrypt_copy_cb,
- ssldecrypt_update_cb,
+ NULL,
ssldecrypt_free_cb,
ssl_parse_uat,
sslkeylist_uats_flds);
uat_channel_t *ud = (uat_channel_t *)p;
if (ud->channel >= 64) {
- *err = wmem_strdup_printf(wmem_packet_scope(), "Channel must be between 0-63.");
+ *err = g_strdup("Channel must be between 0-63.");
return;
}
}
uat_key_record_t* rec = (uat_key_record_t *)r;
if (rec->string == NULL) {
- *err = ep_strdup_printf("Key can't be blank");
+ *err = g_strdup("Key can't be blank");
} else {
g_strstrip(rec->string);
if (rec->string[0] != 0) {
*err = NULL;
if ( !zbee_security_parse_key(rec->string, rec->key, rec->byte_order) ) {
- *err = ep_strdup_printf("Expecting %d hexadecimal bytes or\n"
+ *err = g_strdup_printf("Expecting %d hexadecimal bytes or\n"
"a %d character double-quoted string", ZBEE_SEC_CONST_KEYSIZE, ZBEE_SEC_CONST_KEYSIZE);
}
} else {
- *err = ep_strdup_printf("Key can't be blank");
+ *err = g_strdup("Key can't be blank");
}
}
}
/**
* Initialize GeoIP lookups
*/
-void
+void
geoip_db_pref_init(module_t *nameres)
{
static uat_field_t geoip_db_paths_fields[] = {
static gchar *parse_str;
static guint parse_str_pos;
-#define ERROR(fmtd) do { error = ep_strdup_printf("%s:%d: %s",uat->filename,linenum,ep_strdup_printf fmtd); yyterminate(); } while(0)
+#define ERROR(fmtd) do { \
+ error = ep_strdup_printf("%s:%d: %s",uat->filename,linenum,ep_strdup_printf fmtd); \
+ yyterminate(); \
+} while(0)
#define SET_FIELD() \
{ const gchar* errx; \
<END_OF_RECORD>{newline} {
void* rec;
- const gchar* err = NULL;
+ const char* err = NULL;
linenum++;
uat->update_cb(rec,&err);
if (err) {
- ERROR(("%s",err));
+ char *tmp = ep_strdup(err);
+ /* XXX bit of a hack to remove emem from dissectors, this can
+ * be removed as proper use of glib memory is propogated
+ * through the rest of the UAT code */
+ g_free((char*)err);
+ ERROR(("%s",tmp));
}
valid_record = TRUE;
{
uat_plen_record_t *rec = (uat_plen_record_t*)r;
if (rec->packet_range->nranges < 1) {
- *err = ep_strdup_printf("Invalid range string");
+ *err = g_strdup("Invalid range string");
return;
}
dd->uat->update_cb(dd->rec, &err);
if (err) {
- err = ep_strdup_printf("error updating record: %s", err);
+ char *tmp;
+ tmp = ep_strdup_printf("error updating record: %s", err);
+ /* XXX bit of a hack to remove emem from dissectors, this can
+ * be removed as proper use of glib memory is propogated
+ * through the rest of the UAT code */
+ g_free((char*)err);
+ err = tmp;
goto on_failure;
}
}