]> git.sesse.net Git - vlc/blobdiff - modules/access/rtsp/real_asmrp.c
realrtsp: don't write outside a static buffer.
[vlc] / modules / access / rtsp / real_asmrp.c
index c37363feae7a6ee390e7e7f991e176b634bd3658..057e230e7823400e3b022b1621aa8384a4e4671f 100644 (file)
@@ -94,7 +94,7 @@ static asmrp_t *asmrp_new (void ) {
 
   p->sym_tab_num = 0;
   p->sym         = ASMRP_SYM_NONE;
-  p->buf         = 0;
+  p->buf         = NULL;
 
   return p;
 }
@@ -595,7 +595,7 @@ static int asmrp_rule (asmrp_t *p) {
   return ret;
 }
 
-static int asmrp_eval (asmrp_t *p, int *matches) {
+static int asmrp_eval (asmrp_t *p, int *matches, int matchsize) {
 
   int rule_num, num_matches;
 
@@ -604,7 +604,7 @@ static int asmrp_eval (asmrp_t *p, int *matches) {
   asmrp_get_sym (p);
 
   rule_num = 0; num_matches = 0;
-  while (p->sym != ASMRP_SYM_EOF) {
+  while (p->sym != ASMRP_SYM_EOF && num_matches < matchsize - 1) {
 
     if (asmrp_rule (p)) {
       lprintf ("rule #%d is true\n", rule_num);
@@ -620,7 +620,7 @@ static int asmrp_eval (asmrp_t *p, int *matches) {
   return num_matches;
 }
 
-int asmrp_match (const char *rules, int bandwidth, int *matches) {
+int asmrp_match (const char *rules, int bandwidth, int *matches, int matchsize) {
 
   asmrp_t *p;
   int      num_matches;
@@ -632,7 +632,7 @@ int asmrp_match (const char *rules, int bandwidth, int *matches) {
   asmrp_set_id (p, "Bandwidth", bandwidth);
   asmrp_set_id (p, "OldPNMPlayer", 0);
 
-  num_matches = asmrp_eval (p, matches);
+  num_matches = asmrp_eval (p, matches, matchsize);
 
   asmrp_dispose (p);