summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2016-09-29 14:32:03 +0200
committerMichael Mann <mmann78@netscape.net>2016-10-03 14:35:37 +0000
commit542c3c6f3a87ba147dd85f2909270cc2ad320e93 (patch)
tree59c28ad0883ea7f4da1299b6e88454b4d0cc1239
parentb90134f703b897811b62b7cfa89b2800e5b8d541 (diff)
downloadwireshark-542c3c6f3a87ba147dd85f2909270cc2ad320e93.tar.gz
ssl: use ws_strtou function.
Change-Id: I947dc83e3b1b853873b5158f234e44ef933c3bcc Reviewed-on: https://code.wireshark.org/review/17982 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/packet-ssl-utils.c20
-rw-r--r--epan/dissectors/packet-ssl.c8
2 files changed, 19 insertions, 9 deletions
diff --git a/epan/dissectors/packet-ssl-utils.c b/epan/dissectors/packet-ssl-utils.c
index 55dae129db..a088b164b5 100644
--- a/epan/dissectors/packet-ssl-utils.c
+++ b/epan/dissectors/packet-ssl-utils.c
@@ -47,6 +47,7 @@
#include <wsutil/str_util.h>
#include <wsutil/report_err.h>
#include <wsutil/pint.h>
+#include <wsutil/strtoi.h>
#include <ws_version_info.h>
#include "packet-x509af.h"
#include "packet-x509if.h"
@@ -4646,11 +4647,18 @@ ssl_parse_key_list(const ssldecrypt_assoc_t *uats, GHashTable *key_hash, const c
handle = ssl_find_appdata_dissector(uats->protocol);
if (handle) {
/* Port to subprotocol mapping */
- int port = atoi(uats->port); /* Also maps "start_tls" -> 0 (wildcard) */
- ssl_debug_printf("ssl_init port '%d' filename '%s' password(only for p12 file) '%s'\n",
- port, uats->keyfile, uats->password);
+ guint16 port = 0;
+ if (ws_strtou16(uats->port, NULL, &port)) {
+ if (port > 0) {
+ ssl_debug_printf("ssl_init port '%d' filename '%s' password(only for p12 file) '%s'\n",
+ port, uats->keyfile, uats->password);
- ssl_association_add(dissector_table_name, main_handle, handle, port, tcp);
+ ssl_association_add(dissector_table_name, main_handle, handle, port, tcp);
+ }
+ } else {
+ if (strcmp(uats->port, "start_tls"))
+ ssl_debug_printf("invalid ssl_init_port: %s\n", uats->port);
+ }
}
end:
@@ -5110,8 +5118,8 @@ ssldecrypt_uat_fld_port_chk_cb(void* r _U_, const char* p, guint len _U_, const
}
if (strcmp(p, "start_tls") != 0){
- const gint i = atoi(p);
- if (i < 0 || i > 65535) {
+ guint16 port;
+ if (!ws_strtou16(p, NULL, &port)) {
*err = g_strdup("Invalid port given.");
return FALSE;
}
diff --git a/epan/dissectors/packet-ssl.c b/epan/dissectors/packet-ssl.c
index f4d3e0426e..c0450dedc2 100644
--- a/epan/dissectors/packet-ssl.c
+++ b/epan/dissectors/packet-ssl.c
@@ -96,6 +96,7 @@
#include <wsutil/utf8_entities.h>
#include <wsutil/str_util.h>
+#include <wsutil/strtoi.h>
#include "packet-tcp.h"
#include "packet-x509af.h"
#include "packet-ocsp.h"
@@ -388,7 +389,8 @@ ssl_cleanup(void)
static void
ssl_parse_uat(void)
{
- guint i, port;
+ guint i;
+ guint16 port;
dissector_handle_t handle;
ssl_set_debug(ssl_debug_file_name);
@@ -418,8 +420,8 @@ ssl_parse_uat(void)
for (i = 0; i < nssldecrypt; i++) {
ssldecrypt_assoc_t *ssl_uat = &(sslkeylist_uats[i]);
ssl_parse_key_list(ssl_uat, ssl_key_hash, "ssl.port", ssl_handle, TRUE);
- if (key_list_stack)
- wmem_stack_push(key_list_stack, GUINT_TO_POINTER(atoi(ssl_uat->port)));
+ if (key_list_stack && ws_strtou16(ssl_uat->port, NULL, &port) && port > 0)
+ wmem_stack_push(key_list_stack, GUINT_TO_POINTER(port));
}
}