[MPlayer-dev-eng] [PATCH] Make mplayer able to handle directories
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Mon Mar 21 18:30:57 CET 2011
On Mon, Mar 21, 2011 at 09:40:39AM +0100, theo wrote:
> On 10/03/2011 10:19, theo wrote:
> > Please find attached a patch that makes mplayer able to recursively add
> > files within a directory (or within the directories within) to the
> > play-list.
>
> Is there a chance that this patch will be accepted upstream?
>
> Should I do something to make it possible?
The problem I see with it is that there's no special option
required to make it do recursive.
Most other programs require a -r option or similar for that.
The reason I consider this relevant is that it happens quite
easily that you specify a directory by accident.
And in that case several bad things might happen:
1) Particularly with a network file system it might take long
time to fill up everything and aborting MPlayer may be difficult
2) It might be a local directory with 1000s of very short files,
in which case MPlayer will open and close windows so fast
the system might slow down to a crawl and you will have trouble
terminating MPlayer.
There's also some purely code issues like that
+ while (len>size)
+ size<<=2; can be an endless loop.
I suspect that for the right input these
+ len=strlen(file)+1+strlen(child_file->d_name)+1;
[...]
+ strncpy(child_dir, file, strlen(file));
result first in a integer overflow and then in a buffer overflow.
Using av_strlcpy and av_strlcat should help you avoid at least
the buffer overflows, using standard C string functions is very
much not advisable.
Except possibly snprintf, that might actually work a lot better
here.
Performance will be much worse, but I think simpler code matters
more here. Due to that I'd actually suggest to use
mp_strings.h:char *mp_asprintf(const char *fmt, ...);
More information about the MPlayer-dev-eng
mailing list