]> granicus.if.org Git - rtmpdump/commitdiff
Don't do strchr on a string that isn't necessarily null-terminated
authorMartin Storsjo <martin@martin.st>
Thu, 15 Aug 2013 10:37:19 +0000 (13:37 +0300)
committerMartin Storsjo <martin@martin.st>
Thu, 15 Aug 2013 10:37:19 +0000 (13:37 +0300)
librtmp/rtmp.c

index 9c32bacbc3afdbc467c174e637ad434bf50e9cb7..0b9264d94a101608e93473e331f610cba7005eac 100644 (file)
@@ -2503,6 +2503,16 @@ static void hexenc(unsigned char *inbuf, int len, char *dst)
     *ptr = '\0';
 }
 
+static char *
+AValChr(AVal *av, char c)
+{
+  int i;
+  for (i = 0; i < av->av_len; i++)
+    if (av->av_val[i] == c)
+      return &av->av_val[i];
+  return NULL;
+}
+
 static int
 PublisherAuth(RTMP *r, AVal *description)
 {
@@ -2774,7 +2784,7 @@ PublisherAuth(RTMP *r, AVal *description)
           /* hash2 = hexenc(md5(method + ":/" + app + "/" + appInstance)) */
           /* Extract appname + appinstance without query parameters */
          apptmp = r->Link.app;
-         ptr = strchr(apptmp.av_val, '?');
+         ptr = AValChr(&apptmp, '?');
          if (ptr)
            apptmp.av_len = ptr - apptmp.av_val;