Opened 2 years ago

Last modified 2 years ago

#9274 new defect

avio_open_dir / avio_close_dir seems to be broken

Reported by: rudolfs.bundulis Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: avio_close_dir, avio_open_dir
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:

when using avio_open_dir / avio_close_dir, avio_close_dir manages to close fd 0, thus messing up further open calls. Found this while making a video filter that was enumerating a directory and used these functions for the enumeration. Further open() calls returned 0 and I was not able to understand why. Removing a call to avio_close_dir() fixed that, and then when debugging found that this is what happens:

1) avio_close_dir() calls ffurl_close()
2) ffurl_close() calls ffurl_closep()
3) ffurl_closep() does

if (h->is_connected && h->prot->url_close)

ret = h->prot->url_close(h);

where for file protocol url_close is set to file_close, which
when invoked will call close on c->fd which has never been set in case of a

For me I'll just fallback to plain POSIX calls for this and seems that ffmpeg code base is not using these calls anywhere, but then at least to save others some amount of gray hair this should either be fixed (not sure what is the best approach) or at least calls marked as unsafe?

Change History (1)

comment:1 by rudolfs.bundulis, 2 years ago

Component: undeterminedavformat
Keywords: avio_close_dir avio_open_dir added
Version: unspecifiedgit-master
Note: See TracTickets for help on using tickets.