[vlc-devel] [vlc-commits] es_out_timeshift: Add missing	vlc_mkdir error check
    Rémi Denis-Courmont 
    remi at remlab.net
       
    Sat Apr  8 15:21:10 CEST 2017
    
    
  
Le torstaina 6. huhtikuuta 2017, 17.56.23 EEST Hugo Beauzée-Luyssen a écrit :
> On Thu, Apr 6, 2017, at 05:51 PM, Rémi Denis-Courmont wrote:
> > Le torstaina 6. huhtikuuta 2017, 17.49.08 EEST Hugo Beauzée-Luyssen a
> > 
> > écrit :
> > > vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Apr 
> > > 6
> > > 17:36:20 2017 +0200| [5950581aa62fa16d0ccbbf9f80c21cf0b2e16346] |
> > > committer: Hugo Beauzée-Luyssen
> > > 
> > > es_out_timeshift: Add missing vlc_mkdir error check
> > > 
> > > CID #1398381
> > > 
> > > > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5950581aa62fa16
> > > > d0cc
> > > > bbf9f80c21cf0b2e16346
> > > 
> > > ---
> > > 
> > >  src/input/es_out_timeshift.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
> > > index c4d1820..7172fc3 100644
> > > --- a/src/input/es_out_timeshift.c
> > > +++ b/src/input/es_out_timeshift.c
> > > @@ -1651,7 +1651,8 @@ static int GetTmpFile( char **filename, const char
> > > *dirname ) && asprintf( filename, "%s"DIR_SEP
> > > PACKAGE_NAME"-timeshift.XXXXXX", dirname ) >= 0 )
> > > 
> > >      {
> > > 
> > > -        vlc_mkdir( dirname, 0700 );
> > > +        if( vlc_mkdir( dirname, 0700 ) < 0 )
> > > +            return -1;
> > 
> > So if the directory already exists, I cannot save the file. You must have
> > thought and tested this through so much...
> Fair enough, commit removed.
> I'll fix it properly at a later time.
If mkdir() fails and errno is EEXIST, we know that the directory exists (or 
rather existed in the very recent past) but not if we can write into it. If 
errno is another value, we know that directory creation failed but we do not 
know if the directory exists and is writable, since one error code can hide 
another.
So I am not sure what you imply by "fix[ing] it properly". It seems to me that 
the old code was correct in all cases.
-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/
    
    
More information about the vlc-devel
mailing list