Avoid buffer overflow

(local account needed, but possibly not same user as VLC)
This commit is contained in:
Rémi Denis-Courmont 2005-07-11 16:34:47 +00:00
parent d367c2f58e
commit 51166b9860

View File

@ -525,7 +525,7 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
char **ppsz_hosts = NULL;
int i_hosts = 0;
int i;
int i, i_dirlen;
#ifdef HAVE_SYS_STAT_H
if( stat( psz_dir, &stat_info ) == -1 || !S_ISDIR( stat_info.st_mode ) )
@ -540,6 +540,13 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
return VLC_EGENERIC;
}
i_dirlen = strlen( psz_dir );
if( i_dirlen + 10 > MAX_DIR_SIZE )
{
msg_Warn( p_intf, "skipping too deep dir (%s)", psz_dir );
return 0;
}
msg_Dbg( p_intf, "dir=%s", psz_dir );
sprintf( dir, "%s/.access", psz_dir );
@ -621,10 +628,10 @@ static int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
break;
}
if( p_dir_content->d_name[0] == '.' )
{
if( ( p_dir_content->d_name[0] == '.' )
|| ( i_dirlen + strlen( p_dir_content->d_name ) > MAX_DIR_SIZE ) )
continue;
}
sprintf( dir, "%s/%s", psz_dir, p_dir_content->d_name );
if( ParseDirectory( p_intf, psz_root, dir ) )
{