Skip to contentSkip to conversation

atsc_epg 64-bit bug / fault tolerance

PATCH Mike Slegeir 1 participant 1 message May 12, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

I was looking at using the dvb-apps when I had a hangup with atsc_epg. This issue had been previously reported from what I found at http://www.mail-archive.com/[email protected]/msg44661.html but had not been resolved from what I could tell. Below I'm including a patch to fix the segfault on 64-bit builds and also to improve tolerance of the fault I found when a segment was read with a mode of '?' (don't ask me why, but I could try to give more information if desired). The first three changes in the patch are about using an appropriately sized type rather than casting a pointer to a larger type; this fixes the segfault. The last change involves nulling the title text when it fails to parse rather than failing altogether.

Thanks,
Mike Slegeir

util/atsc_epg/atsc_epg.c Sat May 12 18:15:04 2012 -0500 renamed from util/atsc_epg/atsc_epg.c Tue Apr 10 16:44:06 2012 +0200 +12 -9
diff -r 4030c51d6e7b util/atsc_epg/atsc_epg.c
@@ -60,8 +60,8 @@
 void (*old_handler)(int);
 
 struct atsc_string_buffer {
-    int buf_len;
-    int buf_pos;
+    size_t buf_len;
+    size_t buf_pos;
     char *string;
 };
 
@@ -507,8 +507,8 @@
             event->msg_pos = channel->msg_buf.buf_pos;
             if(0 > atsc_text_segment_decode(seg,
                 (uint8_t **)&channel->msg_buf.string,
-                (size_t *)&channel->msg_buf.buf_len,
-                (size_t *)&channel->msg_buf.buf_pos)) {
+ &channel->msg_buf.buf_len,
+ &channel->msg_buf.buf_pos)) {
                 fprintf(stderr, "%s(): error calling "
                     "atsc_text_segment_decode()\n",
                     __FUNCTION__);
@@ -653,15 +653,18 @@
                 e_info->title_pos = curr_info->title_buf.buf_pos;
                 if(0 > atsc_text_segment_decode(seg,
                     (uint8_t **)&curr_info->title_buf.string,
-                    (size_t *)&curr_info->title_buf.buf_len,
-                    (size_t *)&curr_info->title_buf.buf_pos)) {
+ &curr_info->title_buf.buf_len,
+ &curr_info->title_buf.buf_pos)) {
                     fprintf(stderr, "%s(): error calling "
                         "atsc_text_segment_decode()\n",
                         __FUNCTION__);
-                    return -1;
+                    e_info->title_len = 0;
                 }
-                e_info->title_len = curr_info->title_buf.buf_pos -
-                    e_info->title_pos + 1;
+                else
+                {
+                    e_info->title_len = curr_info->title_buf.buf_pos -
+                        e_info->title_pos + 1;
+                }
             }
         }
     }