summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-k12.c3
-rw-r--r--epan/libwireshark.def1
-rw-r--r--epan/strutil.c14
-rw-r--r--epan/strutil.h10
4 files changed, 27 insertions, 1 deletions
diff --git a/epan/dissectors/packet-k12.c b/epan/dissectors/packet-k12.c
index 398893a218..42878cf7d9 100644
--- a/epan/dissectors/packet-k12.c
+++ b/epan/dissectors/packet-k12.c
@@ -38,6 +38,7 @@
#include <epan/emem.h>
#include <epan/uat.h>
#include <epan/expert.h>
+#include <epan/strutil.h>
#include "packet-sscop.h"
typedef struct _k12_hdls_t {
@@ -135,7 +136,7 @@ static void dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree) {
if (! handles ) {
for (i=0 ; i < nk12_handles; i++) {
- if ( strcasestr(pinfo->pseudo_header->k12.stack_file, k12_handles[i].match) ) {
+ if ( epan_strcasestr(pinfo->pseudo_header->k12.stack_file, k12_handles[i].match) ) {
handles = k12_handles[i].handles;
break;
}
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index 5e9d5bcda7..004f31ef65 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -243,6 +243,7 @@ epan_dissect_run
epan_get_version
epan_init
epan_base64_decode
+epan_strcasestr
ether_to_str
ex_opt_add
ex_opt_count
diff --git a/epan/strutil.c b/epan/strutil.c
index 365b4e5594..cc8f2c4fab 100644
--- a/epan/strutil.c
+++ b/epan/strutil.c
@@ -966,3 +966,17 @@ g_strlcat(gchar *dst, gchar *src, gsize size)
return strl+strs;
}
#endif
+
+char *
+epan_strcasestr(const char *haystack, const char *needle)
+{
+ gsize hlen = strlen(haystack);
+ gsize nlen = strlen(needle);
+
+ while (hlen-- >= nlen) {
+ if (!g_strncasecmp(haystack, needle, nlen))
+ return (char*) haystack;
+ haystack++;
+ }
+ return NULL;
+}
diff --git a/epan/strutil.h b/epan/strutil.h
index 10bf242da4..5e5eac1df4 100644
--- a/epan/strutil.h
+++ b/epan/strutil.h
@@ -205,6 +205,16 @@ guint8 * convert_string_to_hex(const char *string, size_t *nbytes);
*/
char * convert_string_case(const char *string, gboolean case_insensitive);
+/** Finds the first occurence of string 'needle' in string 'haystack'.
+ * The matching is done in a case insensitive manner.
+ *
+ * @param haystack The string possibly containing the substring
+ * @param needle The substring to be searched
+ * @return A pointer into 'haystack' where 'needle' is first found.
+ * Otherwise it returns NULL.
+ */
+char * epan_strcasestr(const char *haystack, const char *needle);
+
/* g_strlcat() does not exist in GLib 1.2[.x] */
#if GLIB_MAJOR_VERSION < 2
gsize g_strlcat(gchar *dst, gchar *src, gsize size);