Hi all,

Looking in the rlm modules, its set up for ASCII. I have stripped down the rlm modules to a simple c program that encodes an accented string and outputs it.

I then removed all other Riv code and tested it.

Here are the results:

All accented characters crash with a core dump
Weirdly:
"This will not crash" crashes
"This will not" is fine

So perhaps some sort of too many spaces crash?

All the crashes happen the same way:

*** stack smashing detected ***: ./encodetest terminated
Aborted (core dumped)

I don't know how to get better debugging in C to isolate it but its definitely the way Riv handles URL encoding in the rlm modules.

There is a fix however I'm nervous about memory management as I can see a case where I could cause a buffer over run with a string that has a lot of accented/weird characters (C is not my preferred language).

The fix is actually fairly simple:

http://rosettacode.org/wiki/URL_encoding#C

If you replace Rivs encode with the functions shown at that link it works fine.

I've attached a diff for the icecast2 rlm module as an example but USE AT YOUR OWN RISK!!!!

The substitute loop should probably be moved to the rlm module start but hopefully this will give someone better in C than me something to go on.

Feel free to reply if all I've done is confuse you.

Regards,

Wayne Merricks
The Voice Asia

On 28/02/14 13:06, Joe Panarello wrote:

Hi;

I been struggling with this problem for the last 2 years. Does anyone have any info on this issue?

I am using the latest version of RD on the appliance OS. When I broadcast and a song Title that has a parenthesis (') in it i.e. (Let's Dance) the Now and Next freezes.

Additionally I also place the Artist and Title in the Display window on RDAirplay and that vanishes also. Sometimes it will return after a few minutes of no parenthesis. Any help would be greatly appreciated.

Best

Joe


--- rivendell-2.5.0/rlm/rlm_icecast2.c	2011-12-22 16:55:39.000000000 +0000
+++ rlm_icecast2.c	2014-02-28 13:32:50.518000327 +0000
@@ -33,6 +33,7 @@
 #include <strings.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <ctype.h> //ctype needed for UTF8 encode
 
 #include <rlm/rlm.h>
 
@@ -47,6 +48,9 @@
 int *rlm_icecast2_aux1s;
 int *rlm_icecast2_aux2s;
 
+//Maps for RFC3986 & HTML5 ASCII substitutions
+char rfc3986[256] = {0};
+char html5[256] = {0};
 
 int rlm_icecast2_BufferDiff(char *sString,int dOrigin,int dDiff,int dMaxSize)
 {
@@ -91,6 +95,20 @@
   return -1; 
 }
 
+void rlm_icecast1_encodeUTFCompat(unsigned char *s, char *enc, char *tb){
+
+  for(; *s; s++){
+
+    if(tb[*s]) 
+      sprintf(enc, "%c", tb[*s]);
+    else
+      sprintf(enc, "%%%02X", *s);
+
+    while(*++enc);
+
+  }
+
+}
 
 int rlm_icecast2_EncodeString(char *sString,int dMaxSize)
 {
@@ -272,7 +290,29 @@
     if((flag==1)||((flag==2)&&(log->log_onair!=0))) {
       strncpy(str,RLMResolveNowNext(ptr,now,next,
 				    rlm_icecast2_formats+256*i),256);
-      rlm_icecast2_EncodeString(str,1023);
+
+      //rlm_shoutcast1_EncodeString(str,1023);
+      /* rlm_shoutcast1_EncodeString only works for ASCII */
+      /* Create an array big enough to store str * 3 if all need to be URL encoded
+       * e.g. ' ' becomes '%20' = 1 char ==> 3 chars
+       */
+      char enc[sizeof(str) * 3];
+      
+      //Loop through standard ASCII symbols and substitute ~, -, . etc as required
+      int j;
+
+      for(j = 0; j < 256; j++){
+
+        rfc3986[j] = isalnum(j) || j == '~' || j == '-' || j == '.' || j == '_'
+            ? j : 0;
+        html5[j] = isalnum(j) || j == '*' || j == '-' || j == '.' || j == '_'
+            ? j: (j == ' ') ? '+' : 0;
+
+      }
+      
+      //Encode str into enc using the rfc3986 subsitutions
+      rlm_shoutcast1_encodeUTFCompat(str, enc, rfc3986);
+      
       snprintf(account,1024,"%s:%s",rlm_icecast2_usernames+256*i,
 	       rlm_icecast2_passwords+256*i);
       snprintf(url,1024,"http://%s:%d/admin/metadata?mount=%s&mode=updinfo&song=%s";,
_______________________________________________
Rivendell-dev mailing list
[email protected]
http://caspian.paravelsystems.com/mailman/listinfo/rivendell-dev

Reply via email to