[FFmpeg-devel] [PATCH] set FONTCONFIG_PATH relative to ffmpeg binary, if it is a static build

Nicolas George george at nsup.org
Mon Feb 17 15:43:23 CET 2014

Le nonidi 29 pluviôse, an CCXXII, Reimar Döffinger a écrit :
> >> There is something fishy about this: getcwd() will return you the path where
> >> ffmpeg was started from too. There is no reliable portable way of finding
> >> the path of the binary that started a program.

> It depends in which context you define reliable.
> If you only think of the shell or system() calls and don't consider people
> being careless with exec arguments then combining cwd and path from
> argv[0] should work.

That is the reason I added "reliable" in the first place: this method will
work most times, but can fail especially with wrappers and GUI.

> If there are better OS-specific methods, having such a function that does
> the best possible in libavutil might be nice...

That is right, av_get_application_path() would probably be a useful
function, provided the doc urges people not tu abuse it.

For Linux systems, readlink("/proc/self/exe") should do the trick quite

> There are good security arguments to not accept relative paths, so
> fontconfig might ignore them on purpose.

I checked before posting:

$ FONTCONFIG_PATH=../fonts strace fc-list |& grep fonts | head -n 2
access("../fonts/fonts.conf", R_OK)     = -1 ENOENT (No such file or directory)
access("/etc/fonts/fonts.conf", R_OK)   = 0

It accepts them.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140217/e51c9639/attachment.asc>

More information about the ffmpeg-devel mailing list