Opened 12 years ago
Closed 12 years ago
#1904 closed defect (fixed)
image2: cannot open files not readable by owner
Reported by: | robert | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | git-master | Keywords: | image2 |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | yes |
Description
Summary of the bug:
file_check() in libavformat/file.c makes loading of image2 sequences fail (not tried with other types of files but I guess it afects all users of this function). The problem is that it checks if the owner has read permissions, but a file can be readable even when the owner has no read permissions if "others" have read permission. This tipically happens on Android systems, for example in the removable sdcard mounted as /mnt/sdcard.
How to reproduce:
Call avformat_open_input() with an image filename in a directory that is not readable by the owner. For example, in a directory with the following permissions: ----r-xr-x
Proposed fix:
divVerent in #ffmpeg@irc.freenode.net proposed this fix:
static int file_check(URLContext *h, int mask) { int ret = 0; if(mask&AVIO_FLAG_READ) if(access(h->filename, R_OK) >= 0) ret |= AVIO_FLAG_READ; if(mask&AVIO_FLAG_WRITE) if(access(h->filename, W_OK) >= 0) ret |= AVIO_FLAG_WRITE; return ret; }
i.e use access() instead of stat(). But he says access() has issues on Windows...
Attachments (1)
Change History (8)
comment:1 by , 12 years ago
Priority: | critical → normal |
---|
comment:2 by , 12 years ago
Status: | new → open |
---|
follow-up: 6 comment:3 by , 12 years ago
Did you test above patch?
Isn't open() refusing to open files if the user does not have the relevant permission himself?
by , 12 years ago
Attachment: | patchor.diff added |
---|
comment:5 by , 12 years ago
Analyzed by developer: | set |
---|---|
Keywords: | image2 added |
Reproduced by developer: | set |
The patch works fine for this use-case:
$ ls -l tests/lena.pnm
--w----r-- 1 root root 196668 Oct 21 19:06 tests/lena.pnm
comment:6 by , 12 years ago
Replying to cehoyos:
Did you test above patch?
Isn't open() refusing to open files if the user does not have the relevant permission himself?
Hi cehoyos, I know it's odd but on Android you find those permissions, maybe because every app runs on its own sandbox with its own user, so it wouldn't make sense to make the files owned by a single user. I don't know, it's just an idea...
Regarding your question about open()... it won't fail if "others" have read permission even when the "owner" has no read permissions. If you think your patch is better it's ok, I'm mostly a java programmer and I don't know much about the C apis.
This stackoverflow.com question is related to this issue and the solution is similar to yours: http://stackoverflow.com/questions/7867853/android-ffmpeg-halfninja-av-open-input-file-returns-2-no-such-file-or-director
Thank your for your fast response.
comment:7 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
Please send patches to ffmpeg-devel mailing list.