diff options
author | Evan Huus <eapache@gmail.com> | 2013-10-25 22:14:25 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2013-10-25 22:14:25 +0000 |
commit | 95f484a91ee34ea3caa2c325170e52d0bf07489b (patch) | |
tree | 83a02ff6f4f38f36c739e437881a432c75eb88b6 /asn1/snmp | |
parent | 7a3febacac8fd14009dc82dc4d139ee43d37a437 (diff) |
Add a very small hack to make the UAT update callback error string freeable, and
convert all existing UAT update callbacks to use glib memory instead of
ephemeral memory for that string.
UAT code paths are entirely distinct from packet dissection, so using ephemeral
memory was the wrong choice, because there was no guarantees about when it would
be freed.
The move away from emem still needs to be propogated deeper into the UAT code
itself at some point.
Net effect: remove another bunch of emem calls from dissectors, where replacing
with wmem would have caused assertions.
svn path=/trunk/; revision=52854
Diffstat (limited to 'asn1/snmp')
-rw-r--r-- | asn1/snmp/packet-snmp-template.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c index 54b2338d69..5e7456ed4f 100644 --- a/asn1/snmp/packet-snmp-template.c +++ b/asn1/snmp/packet-snmp-template.c @@ -2230,7 +2230,7 @@ static void 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; @@ -2240,14 +2240,14 @@ snmp_users_update_cb(void* p _U_, const char** err) 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); } @@ -2257,21 +2257,21 @@ snmp_users_update_cb(void* p _U_, const char** err) 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; |