aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/nettrace_3gpp_32_423.c
diff options
context:
space:
mode:
authorJon <jon@jon-ryzen>2023-09-27 13:51:07 -0500
committerAndersBroman <a.broman58@gmail.com>2023-09-28 07:19:19 +0000
commit82e80778f19a9e877592f7684bd14dd9308d4320 (patch)
tree3d57f372a093a56e73b69f454728180ee1101a76 /wiretap/nettrace_3gpp_32_423.c
parent5c7d0376ad2a217ce55f8da493122d2ca13b0923 (diff)
Added limits on regular expressions
Diffstat (limited to 'wiretap/nettrace_3gpp_32_423.c')
-rw-r--r--wiretap/nettrace_3gpp_32_423.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c
index a939bb4408..337379249c 100644
--- a/wiretap/nettrace_3gpp_32_423.c
+++ b/wiretap/nettrace_3gpp_32_423.c
@@ -126,20 +126,22 @@ nettrace_parse_address(char* curr_pos, char* next_pos, gboolean is_src_addr, exp
ws_in6_addr ip6_addr;
guint32 ip4_addr;
char *ptr; //for strtol function
-
- static GRegex* aregex = NULL;
- static GRegex* pregex = NULL;
- static GRegex* tregex = NULL;
+
+ static GRegex* aregex = NULL; //For IPv4 or IPv6 address
+ static GRegex* pregex = NULL; //For Port
+ static GRegex* tregex = NULL; //For Transport
if (aregex == NULL)
- aregex = g_regex_new ("^.*address\\s*=*\\s*\\[?((?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:[0-9a-f:]*))", G_REGEX_CASELESS | G_REGEX_FIRSTLINE, 0, NULL);
+ //First time will compile regex
+ aregex = g_regex_new ("^.*address\\s*=*\\s*\\[?((?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:[0-9a-f:]{,39}))", G_REGEX_CASELESS | G_REGEX_FIRSTLINE, 0, NULL);
if (pregex == NULL)
- pregex = g_regex_new ("^.*port\\s*=*\\s*(\\d*)", G_REGEX_CASELESS | G_REGEX_FIRSTLINE, 0, NULL);
+ //First time will compile regex
+ pregex = g_regex_new ("^.*port\\s*=*\\s*(\\d{1,5})", G_REGEX_CASELESS | G_REGEX_FIRSTLINE, 0, NULL);
if (tregex == NULL)
- tregex = g_regex_new ("^.*transport\\s*=*\\s*(\\w*)", G_REGEX_CASELESS | G_REGEX_FIRSTLINE, 0, NULL);
-
+ //First time will compile regex
+ tregex = g_regex_new ("^.*transport\\s*=*\\s*(\\w{3,4})", G_REGEX_CASELESS | G_REGEX_FIRSTLINE, 0, NULL);
/* curr_pos pointing to first char of address */