aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/asn1/snmp
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2017-02-19 22:02:04 +0100
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2017-02-20 13:30:18 +0000
commit52ce1b03e04e9a941b1df599214ce205aeafe3e0 (patch)
tree622670037ffb0f4996d3a938a13ebd23186be3bc /epan/dissectors/asn1/snmp
parent1089211c0b0aca7d95b4f54ca0e61d070555e896 (diff)
SNMP: fix insertion of first entry in SNMP Users UAT
when using the GUI to add the first entry, num_ueas is still 0. Change-Id: Iea03495a2e5e39b71391a01454aec5fb6e2b05eb Reviewed-on: https://code.wireshark.org/review/20191 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/dissectors/asn1/snmp')
-rw-r--r--epan/dissectors/asn1/snmp/packet-snmp-template.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/epan/dissectors/asn1/snmp/packet-snmp-template.c b/epan/dissectors/asn1/snmp/packet-snmp-template.c
index 3ee10c4fc0..bb36534d4d 100644
--- a/epan/dissectors/asn1/snmp/packet-snmp-template.c
+++ b/epan/dissectors/asn1/snmp/packet-snmp-template.c
@@ -1369,35 +1369,31 @@ snmp_users_update_cb(void* p _U_, char** err)
*err = NULL;
- if (num_ueas == 0)
- /* Nothing to update */
- return FALSE;
-
- if (! ue->user.userName.len)
+ if (! ue->user.userName.len) {
g_string_append_printf(es,"no userName\n");
-
- for (i=0; i<num_ueas-1; i++) {
- snmp_ue_assoc_t* u = &(ueas[i]);
-
+ } else if ((ue->engine.len > 0) && (ue->engine.len < 5 || ue->engine.len > 32)) {
/* RFC 3411 section 5 */
- if ((u->engine.len > 0) && (u->engine.len < 5 || u->engine.len > 32)) {
- 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->user.userName.len == ue->user.userName.len
- && u->engine.len == ue->engine.len && (u != ue)) {
-
- 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 */
- g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
+ g_string_append_printf(es, "Invalid engineId length (%u). Must be between 5 and 32 (10 and 64 hex digits)\n", ue->engine.len);
+ } else if (num_ueas) {
+ for (i=0; i<num_ueas-1; i++) {
+ snmp_ue_assoc_t* u = &(ueas[i]);
+
+ if ( u->user.userName.len == ue->user.userName.len
+ && u->engine.len == ue->engine.len && (u != ue)) {
+
+ 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 */
+ g_string_append_printf(es,"Duplicate key (userName='%s')\n",ue->user.userName.data);
+ break;
+ }
}
- }
- if (u->engine.len == 0) {
- if ( memcmp( u->user.userName.data, ue->user.userName.data, ue->user.userName.len ) == 0 ) {
- g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\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 ) {
+ g_string_append_printf(es,"Duplicate key (userName='%s' engineId=NONE)\n",ue->user.userName.data);
+ break;
+ }
}
}
}