From: "Martin Storsjö" <martin@martin.st>
To: Timo Rothenpieler <timo@rothenpieler.org>
Cc: trystan.mata@tytanium.xyz,
FFmpeg development discussions and patches
<ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] mfenc: Use dlopen instead of LoadLibrary for loading mfplat.dll
Date: Thu, 26 May 2022 01:01:34 +0300 (EEST)
Message-ID: <aa6f33b-e5d3-934e-a8e6-cea23c8cdde@martin.st> (raw)
In-Reply-To: <d817e123-b768-340a-9b9a-524c6d24f4bb@rothenpieler.org>
On Wed, 25 May 2022, Timo Rothenpieler wrote:
> On 25/05/2022 23:35, Martin Storsjö wrote:
>> The dlopen wrapper contains code to make loading libraries safer,
>> to avoid loading a potentially malicious DLL with the same name.
>>
>> Signed-off-by: Martin Storsjö <martin@martin.st>
>> ---
>> libavcodec/mfenc.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
>> index 17d0ec60bd..ab0b6b4145 100644
>> --- a/libavcodec/mfenc.c
>> +++ b/libavcodec/mfenc.c
>> @@ -29,6 +29,7 @@
>> #include "libavutil/time.h"
>> #include "codec_internal.h"
>> #include "internal.h"
>> +#include "compat/w32dlfcn.h"
>> typedef struct MFContext {
>> AVClass *av_class;
>> @@ -1158,7 +1159,7 @@ static int mf_load_library(AVCodecContext *avctx)
>> MFContext *c = avctx->priv_data;
>> #if !HAVE_UWP
>> - c->library = LoadLibraryA("mfplat.dll");
>> + c->library = dlopen("mfplat.dll", 0);
>> if (!c->library) {
>> av_log(c, AV_LOG_ERROR, "DLL mfplat.dll failed to open\n");
>> @@ -1191,7 +1192,7 @@ static int mf_close(AVCodecContext *avctx)
>> if (c->library)
>> ff_free_mf(&c->functions, &c->mft);
>> - FreeLibrary(c->library);
>> + dlclose(c->library);
>> c->library = NULL;
>> #else
>> ff_free_mf(&c->functions, &c->mft);
>
> Very much a nit, given this code only ever runs on Windows, and dlsym is
> just a literal define to GetProcAddress, but mixing
> dlopen()+GetProcddress() like that looks kinda weird :D
Ah, yes, it's indeed best to keep it consistent.
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2022-05-25 22:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-25 21:35 Martin Storsjö
2022-05-25 21:42 ` Timo Rothenpieler
2022-05-25 22:01 ` Martin Storsjö [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa6f33b-e5d3-934e-a8e6-cea23c8cdde@martin.st \
--to=martin@martin.st \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=timo@rothenpieler.org \
--cc=trystan.mata@tytanium.xyz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git