[vlc-devel] [PATCH] Smem Stream output module

Rémi Denis-Courmont remi at remlab.net
Thu Aug 20 20:25:59 CEST 2009


Le jeudi 20 août 2009 20:33:34 christophe courtaut, vous avez écrit :
> 2009/8/20 Rémi Denis-Courmont <remi at remlab.net>:
> > Le jeudi 20 août 2009 15:58:34 christophe courtaut, vous avez écrit :
> >> On Thu, Aug 20, 2009 at 2:08 PM, Rafaël Carré<rafael.carre at gmail.com> 
wrote:
> >> > On Thu, 20 Aug 2009 13:48:17 +0200
> >> > christophe courtaut <christophe.courtaut at gmail.com> wrote:
> >> >
> >> > Hi, i have a few small comments
> >> >
> >> >> From d51e0d64fb952f3b5f78c89ea12183dce7231806 Mon Sep 17 00:00:00
> >> >> 2001 From: Christophe Courtaut <christophe.courtaut at gmail.com>
> >> >> Date: Fri, 31 Jul 2009 15:59:09 +0200
> >> >> Subject: [PATCH] Functionnal version of smem stream output module
> >> >>
> >> >> +    psz_tmp = var_CreateGetString( p_stream, SOUT_PREFIX_VIDEO
> >> >> "chroma" );
> >> >> +    memcpy( &p_sys->i_video_chroma, psz_tmp, 4 );
> >> >> +    free( psz_tmp );
> >> >
> >> > you should use strncpy to check psz_tmp len
> >>
> >> I now use strncpy, but strncpy does'nt allow you to check how many
> >> bytes where copied, as it returns a pointer to dest.
> >
> > That's why we have strlcpy().
>
> strlcpy should do the thing, but it insert a '\0' at the end of the
> buffer, and i'm copying the four char of the string into a
> vlc_fourcc_t.
>
> Any other ideas?

In your case, I'd check that strlen() is at least 3 (4 bytes nul included), 
and then memcpy().

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list