summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2016-09-22 14:45:52 +0200
committerMichael Mann <mmann78@netscape.net>2016-09-25 02:55:52 +0000
commit3c9fb071191a211af756faedd7647cf80e542639 (patch)
tree1a88a219b852bf668eec50aaa8465b54d0d431f6
parent06b09eea72ecbfe937a89a5887274e445b4c1bbf (diff)
downloadwireshark-3c9fb071191a211af756faedd7647cf80e542639.tar.gz
iscsi: use ws_strtou functions.
Add expert info for failed conversion. Change-Id: I03d5e2db791f81d43384bb047c268d07709a6099 Reviewed-on: https://code.wireshark.org/review/17863 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/packet-iscsi.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c
index e62b7b796a..f1764b7841 100644
--- a/epan/dissectors/packet-iscsi.c
+++ b/epan/dissectors/packet-iscsi.c
@@ -37,9 +37,11 @@
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/conversation.h>
+#include <epan/expert.h>
#include "packet-scsi.h"
#include <epan/crc32-tvb.h>
#include <wsutil/crc32.h>
+#include <wsutil/strtoi.h>
void proto_register_iscsi(void);
void proto_reg_handoff_iscsi(void);
@@ -201,6 +203,8 @@ static gint ett_iscsi_lun = -1;
static gint ett_iscsi_ISID = -1;
/* #endif */
+static expert_field ei_iscsi_keyvalue_invalid = EI_INIT;
+
enum iscsi_digest {
ISCSI_DIGEST_AUTO,
ISCSI_DIGEST_NONE,
@@ -521,10 +525,10 @@ typedef struct _iscsi_conv_data {
(it starts to be common to use redirectors to point to non-3260 ports)
*/
static void
-iscsi_dissect_TargetAddress(packet_info *pinfo, proto_tree *tree _U_,char *val)
+iscsi_dissect_TargetAddress(packet_info *pinfo, tvbuff_t* tvb, proto_tree *tree, char *val, guint offset)
{
address *addr = NULL;
- int port;
+ guint16 port;
char *value = wmem_strdup(wmem_packet_scope(), val);
char *p = NULL, *pgt = NULL;
@@ -569,7 +573,10 @@ iscsi_dissect_TargetAddress(packet_info *pinfo, proto_tree *tree _U_,char *val)
addr->len = 4;
addr->data = addr_data;
- port = atoi(p);
+ if (!ws_strtou16(p, NULL, &port)) {
+ proto_tree_add_expert_format(tree, pinfo, &ei_iscsi_keyvalue_invalid,
+ tvb, offset + (guint)strlen(value), (guint)strlen(p), "Invalid port: %s", p);
+ }
}
}
@@ -613,11 +620,11 @@ addTextKeys(packet_info *pinfo, proto_tree *tt, tvbuff_t *tvb, gint offset, guin
}
*value++ = 0;
+ proto_tree_add_item(tt, hf_iscsi_KeyValue, tvb, offset, len, ENC_ASCII|ENC_NA);
if (!strcmp(key, "TargetAddress")) {
- iscsi_dissect_TargetAddress(pinfo, tt, value);
+ iscsi_dissect_TargetAddress(pinfo, tvb, tt, value, offset + strlen("TargetAddress") + 2);
}
- proto_tree_add_item(tt, hf_iscsi_KeyValue, tvb, offset, len, ENC_ASCII|ENC_NA);
offset += len;
}
return offset;
@@ -2556,6 +2563,7 @@ void
proto_register_iscsi(void)
{
module_t *iscsi_module;
+ expert_module_t* expert_iscsi;
/* Setup list of header fields See Section 1.6.1 for details*/
static hf_register_info hf[] = {
@@ -3151,6 +3159,14 @@ proto_register_iscsi(void)
"data_digest_size");
prefs_register_obsolete_preference(iscsi_module,
"enable_data_digests");
+
+ static ei_register_info ei[] = {
+ { &ei_iscsi_keyvalue_invalid, { "iscsi.keyvalue.invalid", PI_MALFORMED, PI_ERROR,
+ "Invalid key/value pair", EXPFILL }}
+ };
+
+ expert_iscsi = expert_register_protocol(proto_iscsi);
+ expert_register_field_array(expert_iscsi, ei, array_length(ei));
}