]> granicus.if.org Git - rtmpdump/commitdiff
Set RTMP_PUB_ALLOC if tcUrl is allocated in PublisherAuth
authorMartin Storsjo <martin@martin.st>
Sat, 5 Jul 2014 21:44:29 +0000 (00:44 +0300)
committerMartin Storsjo <martin@martin.st>
Mon, 7 Jul 2014 07:15:17 +0000 (10:15 +0300)
This makes sure we don't free tcUrl in RTMP_Close when reconnecting,
and avoids leaks (or simplifies code to avoid leaks).

This fixes connecting with authentication (both adobe and limelight)
when the app has been specified separately from the rest of the url.

This is only a temporary step while refactoring, this is removed
in a later commit.

librtmp/rtmp.c

index a6ea64da92dcf0d7ed137e84ad7dde793e67913a..75906be96da9998e614a7b1ad71a5809d0d23f65 100644 (file)
@@ -2532,6 +2532,19 @@ PublisherAuth(RTMP *r, AVal *description)
   char salted2[SALTED2_LEN];
   AVal pubToken;
 
+  // If tcUrl is allocated, set RTMP_PUB_ALLOC instead to simplify checks below.
+  // This also avoids accidentally freeing tcUrl in RTMP_Close when reconnecting.
+  if (r->Link.lFlags & RTMP_LF_FTCU && !(r->Link.pFlags & RTMP_PUB_ALLOC))
+    {
+      ptr = malloc(r->Link.app.av_len + 1);
+      strncpy(ptr, r->Link.app.av_val, r->Link.app.av_len);
+      ptr[r->Link.app.av_len] = '\0'; // We use strstr on this string below
+      r->Link.app.av_val = ptr;
+
+      r->Link.lFlags &= ~RTMP_LF_FTCU;
+      r->Link.pFlags |= RTMP_PUB_ALLOC;
+    }
+
   if (strstr(description->av_val, av_authmod_adobe.av_val) != NULL)
     {
       if(strstr(description->av_val, "code=403 need auth") != NULL)