[dvblast-devel] Compile failure on x86_64

Georgi Chorbadzhiyski gf at unixsol.org
Tue Oct 2 10:10:32 CEST 2012


On 10/2/12 8:11 AM, Alexei Takaseev wrote:
>
> System ALT Linux Sisuphus 01-10-2012
> arch x86_64
> glibc 2.16
> gcc version 4.7.2 20120920 (ALT Linux 4.7.2-alt2) (GCC)
>
> Compile failure on x86_64 with:
> =======================================================
> Executing(%build): /bin/sh -e /usr/src/tmp/rpm-tmp.8535
> + umask 022
> + /bin/mkdir -p /usr/src/RPM/BUILD
> + cd /usr/src/RPM/BUILD
> + cd dvblast-2.2
> + make
> make: Entering directory `/usr/src/RPM/BUILD/dvblast-2.2'
> CC      dvblast.c
> CC      util.c
> CC      dvb.c
> CC      udp.c
> CC      asi.c
> CC      demux.c
> CC      output.c
> CC      en50221.c
> In file included from /usr/include/string.h:656:0,
>                   from en50221.c:30:
> In function 'memcpy',
>      inlined from 'TPDUSend.constprop.35' at en50221.c:318:19,
>      inlined from 'SPDUSend' at en50221.c:500:26:
> /usr/include/bits/string3.h:51:3: error: call to __builtin___memcpy_chk will always overflow destination buffer
> make: *** [en50221.o] Error 1
> make: Leaving directory `/usr/src/RPM/BUILD/dvblast-2.2'
> ===========================================================
>
> On the i586 architecture there are no compilation errors.
>
> Has anyone successfully compiled with the combination of x86_64 + gcc 4.7 + glibc 2.16 + last dvblast of git?

Ok, I don't see it:

     313     case T_DATA_LAST:
     314     case T_DATA_MORE:
     315     {
     316         /* i_length <= MAX_TPDU_DATA */
     317         uint8_t *p = p_data + 3;
     318         p = SetLength( p, i_length + 1 );
     319         *p++ = i_tcid;
     320
     321         if ( i_length )
     322             memcpy( p, p_content, i_length );
     323             i_size = i_length + (p - p_data);
     324         }
     325         break;

The memcpy will overflow if i_length is > MAX_TPDU_DATA but we
never called this function with more than MAX_TPDU_DATA set as i_length.
Am I missing something?

This patch probably wrong, but please try it to see if the error goes away:

diff --git a/en50221.c b/en50221.c
index 0724fb3..049c5c2 100644
--- a/en50221.c
+++ b/en50221.c
@@ -205,7 +205,7 @@ static uint8_t *SetLength( uint8_t *p_data, int i_length )
   */

  #define MAX_TPDU_SIZE  4096
-#define MAX_TPDU_DATA  (MAX_TPDU_SIZE - 4)
+#define MAX_TPDU_DATA  (MAX_TPDU_SIZE - 8)

  #define DATA_INDICATOR 0x80


-- 
Georgi Chorbadzhiyski
http://georgi.unixsol.org/


More information about the dvblast-devel mailing list