more robust rtp plus tag parsing
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 8 Nov 2007 23:17:10 +0000 (23:17 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 8 Nov 2007 23:17:10 +0000 (23:17 +0000)
lib/dvb/radiotext.cpp

index eff40e9299f4627279e3ca41155130f7a449d93d..3e057194dec6ef41a9a9c68fce63663c316a958d 100644 (file)
@@ -562,14 +562,20 @@ inline void eDVBRdsDecoder::gotAncillaryData(__u8 *buf, int len)
                                        rtp_len[1]   = 0x1f & rtp_buf[4];
                                                                        
                                        unsigned char rtplus_osd_tmp[64];
-                                                                       
-                                       memcpy(rtp_item[rtp_typ[0]],lastmessage+rtp_start[0],rtp_len[0]+1);
-                                       rtp_item[rtp_typ[0]][rtp_len[0]+1]=0;
+                                       
+                                       if (rtp_start[0] < 66 && (rtp_len[0]+rtp_start[0]) < 66)
+                                       {
+                                               memcpy(rtp_item[rtp_typ[0]],lastmessage+rtp_start[0],rtp_len[0]+1);
+                                               rtp_item[rtp_typ[0]][rtp_len[0]+1]=0;
+                                       }
                                                                        
                                        if (rtp_typ[0] != rtp_typ[1])
                                        {
-                                               memcpy(rtp_item[rtp_typ[1]],lastmessage+rtp_start[1],rtp_len[1]+1);
-                                               rtp_item[rtp_typ[1]][rtp_len[1]+1]=0;
+                                               if (rtp_start[1] < 66 && (rtp_len[1]+rtp_start[1]) < 66)
+                                               {
+                                                       memcpy(rtp_item[rtp_typ[1]],lastmessage+rtp_start[1],rtp_len[1]+1);
+                                                       rtp_item[rtp_typ[1]][rtp_len[1]+1]=0;
+                                               }
                                        }
 
                                        // main RTPlus item_types used by the radio stations: