Browse Source

obs-outputs: Add bounds checking to b64enc

This fixes "warning: unused parameter 'maxsize' [-Wunused-parameter]"
introduced when authentication was turned on.
Jess Mayo 10 years ago
parent
commit
f1a6b37e8e
1 changed files with 12 additions and 4 deletions
  1. 12 4
      plugins/obs-outputs/librtmp/rtmp.c

+ 12 - 4
plugins/obs-outputs/librtmp/rtmp.c

@@ -2365,11 +2365,19 @@ b64enc(const unsigned char *input, int length, char *output, int maxsize)
         return 0;
         return 0;
     }
     }
 #elif defined(USE_ONLY_MD5)
 #elif defined(USE_ONLY_MD5)
-    base64_encodestate state;
+    if ((((length + 2) / 3) * 4) <= maxsize)
+    {
+        base64_encodestate state;
 
 
-    base64_init_encodestate(&state);
-    output += base64_encode_block((const char *)input, length, output, &state);
-    base64_encode_blockend(output, &state);
+        base64_init_encodestate(&state);
+        output += base64_encode_block((const char *)input, length, output, &state);
+        base64_encode_blockend(output, &state);
+    }
+    else
+    {
+        RTMP_Log(RTMP_LOGDEBUG, "%s, error", __FUNCTION__);
+        return 0;
+    }
 
 
 #else   /* USE_OPENSSL */
 #else   /* USE_OPENSSL */
     BIO *bmem, *b64;
     BIO *bmem, *b64;