[FFmpeg-devel] [PATCH] avformat/rtsp: fix getnameinfo() call on FreeBSD

Kevin Lo kevlo at kevlo.org
Fri Nov 25 02:45:07 EET 2016


On Fri, Nov 25, 2016 at 07:13:50AM +0800, Kevin Lo wrote:
> 
> On Thu, Nov 24, 2016 at 04:12:41PM +0100, Nicolas George wrote:
> > Le quartidi 4 frimaire, an CCXXV, Kevin Lo a écrit :
> > > FreeBSD's socket calls require the sockaddr struct length to agree
> > > with the address family, Linux does not.  This patch fixes a failing
> > > getnameinfo() call on FreeBSD.
> > > 
> > > Signed-off-by: Kevin Lo <kevlo at kevlo.org>
> > 
> > I looked at the standard, the semantic of salen is not specified. In
> > doubt, I would consider the usage to be invalid even if it works by
> > happenstance on Linux.
> 
> I know that's not the standard, that's why I added 'ifdef __FreeBSD__'.

Sorry I forgot to mention that I'll resend the patch about adding 
sdp_ip_len, thanks.

> > > ---
> > > 
> > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > > index c6292c5..15fe25d 100644
> > > --- a/libavformat/rtsp.c
> > > +++ b/libavformat/rtsp.c
> > > @@ -2310,7 +2310,11 @@ static int sdp_read_header(AVFormatContext *s)
> > >              AVDictionary *opts = map_to_opts(rt);
> > >  
> > >              err = getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip,
> > 
> > > +#ifdef __FreeBSD__
> > > +                              ((struct sockaddr*) &rtsp_st->sdp_ip)->sa_len,
> > > +#else
> > >                                sizeof(rtsp_st->sdp_ip),
> > > +#endif
> > 
> > On the other hand, sa_len is not standard, and littering the code with
> > ifdefry is ugly. Better add a field sdp_ip_len and set it at the same
> > time as sdp_ip.
> > 
> > Also, there are other instance of the same misuse of getnameinfo() in
> > this file.
> > 
> > >                                namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
> > >              if (err) {
> > >                  av_log(s, AV_LOG_ERROR, "getnameinfo: %s\n", gai_strerror(err));
> > 
> > Regards,
> > 
> > -- 
> >   Nicolas George
> 
> 
> 
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> 


More information about the ffmpeg-devel mailing list