diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-06-29 13:13:55 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2015-06-29 22:57:55 +0000 |
commit | 1e511d830eac041815db3287934b6b84370b8f16 (patch) | |
tree | 5421ca853ad0d57a383f7623dd6a0292f2ad6c64 /epan/dissectors/packet-ssl-utils.c | |
parent | a36db750e4b9002c91899c7a9b774401f2de1b81 (diff) |
ssl: test for file type before reading key file
ftell() is undefined for directories. In practice, it will report
0x7fffffffffffffff on an ext4 filesystem. Ensure that the given key file
is not a directory.
By the way, this is the only user of ftell that is affected.
Bug: 11268
Change-Id: Iaecd42c9b60da9e7945703a794601773749f2d97
Reviewed-on: https://code.wireshark.org/review/9213
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/dissectors/packet-ssl-utils.c')
-rw-r--r-- | epan/dissectors/packet-ssl-utils.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/epan/dissectors/packet-ssl-utils.c b/epan/dissectors/packet-ssl-utils.c index a42ecde748..f59acd6ce5 100644 --- a/epan/dissectors/packet-ssl-utils.c +++ b/epan/dissectors/packet-ssl-utils.c @@ -39,6 +39,7 @@ #include <epan/ipv6-utils.h> #include <epan/expert.h> #include <epan/asn1.h> +#include <wsutil/filesystem.h> #include <wsutil/file_util.h> #include <wsutil/str_util.h> #include <wsutil/report_err.h> @@ -4406,6 +4407,12 @@ ssl_parse_key_list(const ssldecrypt_assoc_t * uats, GHashTable *key_hash, GTree* address_type addr_type[2] = { AT_IPv4, AT_IPv6 }; gchar* address_string; + /* ftell() open open directory is undefined, catch it earlier. */ + if (test_for_directory(uats->keyfile) == EISDIR) { + report_open_failure(uats->keyfile, EISDIR, FALSE); + return; + } + /* try to load keys file first */ fp = ws_fopen(uats->keyfile, "rb"); if (!fp) { |