pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: multimedia/libmp4v2 build failure



On Sun, 30 Aug 2020 20:17:44 +0100
Chavdar Ivanov <ci4ic4%gmail.com@localhost> wrote:

> Hi,
> 
> On -current with gcc 8.4.0 this package fails build with:
> 
> --- util.lo ---
> if /bin/sh ../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H
> -I. -I. -I../.. -I../../include -I../../lib/utils  -I/usr/pkg/include
> -I/usr/X11R7/include -I/usr/X11R7/include/libdrm -I/usr/include
> -DDEBUG -Wall -Werror -O2 -I/usr/pkg/include -I/usr/X11R7/include
> -I/usr/X11R7/include/libdrm -I/usr/include -DMPEG4IP
> -I/usr/pkg/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -D_THREAD_SAFE -MT
> util.lo -MD -MP -MF ".deps/util.Tpo" -c -o util.lo util.c;  then mv -f
> ".deps/util.Tpo" ".deps/util.Plo"; else rm -f ".deps/util.Tpo"; exit
> 1; fi
> libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../.. -I../../include
> -I../../lib/utils
> -I/usr/pkgsrc/multimedia/libmp4v2/work/.buildlink/include
> -I/usr/pkgsrc/multimedia/libmp4v2/work/.x11-buildlink/include
> -I/usr/pkgsrc/multimedia/libmp4v2/work/.x11-buildlink/include/libdrm
> -DDEBUG -Wall -Werror -O2 -DMPEG4IP
> -I/usr/pkgsrc/multimedia/libmp4v2/work/.buildlink/include/SDL
> -D_GNU_SOURCE=1 -D_REENTRANT -D_THREAD_SAFE -MT util.lo -MD -MP -MF
> .deps/util.Tpo -c util.c  -fPIC -DPIC -o .libs/util.o
> --- net_udp.lo ---
> In function 'udp_host_addr4',
>     inlined from 'udp_host_addr' at net_udp.c:1085:10:
> net_udp.c:531:2: error: 'strncpy' specified bound 256 equals
> destination size [-Werror=stringop-truncation]
>   strncpy(hname, inet_ntoa(iaddr), MAXHOSTNAMELEN);
>   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> net_udp.c: In function 'udp_set_multicast_src':
> net_udp.c:1115:10: error: 'strncpy' specified bound 256 equals
> destination size [-Werror=stringop-truncation]
>           strncpy(G_Multicast_Src, src, sizeof(G_Multicast_Src));
>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> ....
> 
> 
> 
> I 'solved' it for the moment with
> 
> --- net_udp.c.orig      2007-09-18 21:52:01.000000000 +0100
> +++ net_udp.c   2020-08-30 20:03:10.019414145 +0100
> @@ -163,9 +163,8 @@
>         va_end(ap);
>         rtp_message(LOG_ALERT, "ERROR: %s, (%d - %s)\n", buffer, e,
> ws_errs[i].errname);
>  #else
> -       uint32_t retlen;
>         va_start(ap, msg);
> -       retlen = vsnprintf(buffer, blen, msg, ap);
> +       (void)vsnprintf(buffer, blen, msg, ap);
>         va_end(ap);
>         rtp_message(LOG_ALERT, "%s:%s", buffer, strerror(errno));
>  #endif
> @@ -529,7 +528,10 @@
>         }
>         ASSERT(hent->h_addrtype == AF_INET);
>         memcpy(&iaddr.s_addr, hent->h_addr, sizeof(iaddr.s_addr));
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wstringop-truncation"
>         strncpy(hname, inet_ntoa(iaddr), MAXHOSTNAMELEN);
> +#pragma GCC diagnostic pop
>         return xstrdup(hname);
>  }
> 
> @@ -1113,7 +1115,10 @@
>  {
>       //TODO - In future use a list and add more that one src
>       if(src !=         NULL) {
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wstringop-truncation"
>           strncpy(G_Multicast_Src, src, sizeof(G_Multicast_Src));
> +#pragma GCC diagnostic pop
>           G_IGMP_V3 = 1;
>       }
>  }
> 
> 
> (the first modification is actually from an existing patch to the
> file, I only added the pragmas, but as far as I understand it strncpy
> should be replaced).

The correct fix for is to use `blen - 1` instead of `blen`
and `sizeof(G_Multicast_Src) - 1` instead of `sizeof(G_Multicast_Src)`,
respectively. Please try that instead?
Warnings about potential buffer overflow should not be pragma'd away.
Especially in network code.


Home | Main Index | Thread Index | Old Index