session: use full charset for RTSP session ID
authorMiguel Angel Cabrera Moya <madmac2501@gmail.com>
Thu, 3 Mar 2011 19:38:03 +0000 (20:38 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 7 Mar 2011 18:39:43 +0000 (18:39 +0000)
As specified in RFC 2326 section 3.4 use full valid charset to make guessing
session ID more difficult.

https://bugzilla.gnome.org/show_bug.cgi?id=643812

gst/rtsp-server/rtsp-session-pool.c

index 36c0211..de9234e 100644 (file)
@@ -30,6 +30,14 @@ enum
   PROP_LAST
 };
 
+static const gchar session_id_charset[] =
+    { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+  'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D',
+  'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
+  'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7',
+  '8', '9', '$', '-', '_', '.', '+'
+};
+
 GST_DEBUG_CATEGORY_STATIC (rtsp_session_debug);
 #define GST_CAT_DEFAULT rtsp_session_debug
 
@@ -235,7 +243,9 @@ create_session_id (GstRTSPSessionPool * pool)
   gint i;
 
   for (i = 0; i < 16; i++) {
-    id[i] = g_random_int_range ('a', 'z');
+    id[i] =
+        session_id_charset[g_random_int_range (0,
+            G_N_ELEMENTS (session_id_charset))];
   }
 
   return g_strndup (id, 16);