[vlc-devel] [PATCH] sftp: implement directory listing

Petri Hintukainen phintuka at users.sourceforge.net
Tue Mar 17 20:51:10 CET 2015


On ma, 2015-03-16 at 10:24 +0100, Jean-Baptiste Kempf wrote:
> On 14 Mar, Petri Hintukainen wrote :
> > +/*****************************************************************************
> > + * Directory access
> > + *****************************************************************************/
> > +
> > +static int DirRead (access_t *p_access, input_item_node_t *p_current_node)
> > +{
> > +    access_sys_t *p_sys = p_access->p_sys;
> > +    LIBSSH2_SFTP_ATTRIBUTES attrs;
> > +    size_t i_size = 1024;
> 
> Why 1024 ?

Just a guess. I didn't find any way to detect the size. I tried growing
buffer after read failure, but seeking back in directory stream didn't work.
It would be possible to retry with larger buffer after closing + re-opening
the directory.

> > +    char *psz_file = malloc( i_size );
> 
> Unchecked malloc.

Fixed

> > +    while( 0 != ( err = libssh2_sftp_readdir( p_sys->file, psz_file, i_size, &attrs ) ) ) {
> > +
> Weird { placement

Fixed
 
> Rest is good.

Updated patch attached.


- Petri

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-sftp-implement-directory-listing.patch
Type: text/x-patch
Size: 6958 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150317/6e536cac/attachment.bin>


More information about the vlc-devel mailing list