Skip to content

Commit 71062a9

Browse files
committed
Update to latest libwebp 1.3.2
This fixes the major libwebp vulnerability that was widely reported on last week, e.g. https://arstechnica.com/security/2023/09/incomplete-disclosures-by-apple-and-google-create-huge-blindspot-for-0-day-hunters/
1 parent f8cf6b4 commit 71062a9

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed
114 KB
Binary file not shown.

App/PhotoDemon/Plugins/libwebp.dll

-9.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Modules/Plugin_Management.bas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Private Const EXPECTED_LITTLECMS_VERSION As String = "2.13.1"
7070
Private Const EXPECTED_LZ4_VERSION As String = "10904"
7171
Private Const EXPECTED_PSPI_VERSION As String = "0.9"
7272
Private Const EXPECTED_RESVG_VERSION As String = "0.35.0"
73-
Private Const EXPECTED_WEBP_VERSION As String = "1.2.4"
73+
Private Const EXPECTED_WEBP_VERSION As String = "1.3.2"
7474
Private Const EXPECTED_ZSTD_VERSION As String = "10505"
7575

7676
'To simplify handling throughout this module, plugin existence, allowance, and successful initialization are tracked internally.
@@ -367,6 +367,7 @@ Private Function GetNonEssentialPluginFiles(ByVal pluginEnumID As CORE_PLUGINS,
367367
dstStringStack.AddString "pspiHost-LICENSE.txt"
368368

369369
Case CCP_libwebp
370+
dstStringStack.AddString "libsharpyuv.dll"
370371
dstStringStack.AddString "libwebpdemux.dll"
371372
dstStringStack.AddString "libwebp-LICENSE.txt"
372373
dstStringStack.AddString "libwebpmux.dll"

Modules/Plugin_WebP.bas

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Attribute VB_Name = "Plugin_WebP"
33
'WebP Library Interface
44
'Copyright 2021-2023 by Tanner Helland
55
'Created: 22/September/21
6-
'Last updated: 23/September/21
7-
'Last update: wrap up initial build
6+
'Last updated: 25/September/23
7+
'Last update: add code for new libwebp dependency (libsharpyuv)
88
'
99
'Per its documentation (available at https://github.com/webmproject/libwebp/), libwebp is...
1010
'
@@ -37,6 +37,10 @@ Option Explicit
3737
' "availability" state by setting m_LibAvailable to FALSE
3838
Private m_hLibWebP As Long, m_hLibWebPDemux As Long, m_hLibWebPMux As Long, m_LibAvailable As Boolean
3939

40+
'As of v1.3.2 (possibly earlier; this was when I updated from 1.2.4), libwebp has an extra dependency on
41+
' libsharpyuv (bundled with PD). We must load this *prior* to loading any other webp dlls.
42+
Private m_hLibSharpYUV As Long
43+
4044
'Forcibly disable libwebp interactions at run-time (if newState is FALSE).
4145
' Setting newState to TRUE is not advised; this module will handle state internally based
4246
' on successful library loading.
@@ -77,14 +81,19 @@ Public Function InitializeEngine(ByRef pathToDLLFolder As String) As Boolean
7781

7882
'Initialize all webp libraries
7983
Dim strLibPath As String
84+
85+
'New to 1.3.2 is the sharpyuv lib which must be loaded *first*
86+
strLibPath = pathToDLLFolder & "libsharpyuv.dll"
87+
m_hLibSharpYUV = VBHacks.LoadLib(strLibPath)
88+
89+
'libwebp can now resolve dependencies correctly...
8090
strLibPath = pathToDLLFolder & "libwebp.dll"
8191
m_hLibWebP = VBHacks.LoadLib(strLibPath)
8292
strLibPath = pathToDLLFolder & "libwebpdemux.dll"
8393
m_hLibWebPDemux = VBHacks.LoadLib(strLibPath)
8494
strLibPath = pathToDLLFolder & "libwebpmux.dll"
8595
m_hLibWebPMux = VBHacks.LoadLib(strLibPath)
86-
87-
m_LibAvailable = (m_hLibWebP <> 0) And (m_hLibWebPDemux <> 0) And (m_hLibWebPMux <> 0)
96+
m_LibAvailable = (m_hLibSharpYUV <> 0) And (m_hLibWebP <> 0) And (m_hLibWebPDemux <> 0) And (m_hLibWebPMux <> 0)
8897
InitializeEngine = m_LibAvailable
8998

9099
If (Not InitializeEngine) Then PDDebug.LogAction "WARNING! LoadLibraryW failed to load one or more WebP libraries. Last DLL error: " & Err.LastDllError
@@ -96,18 +105,25 @@ Public Function IsWebPEnabled() As Boolean
96105
End Function
97106

98107
Public Sub ReleaseEngine()
99-
If (m_hLibWebP <> 0) Then
100-
VBHacks.FreeLib m_hLibWebP
101-
m_hLibWebP = 0
108+
109+
'For extra safety, free in reverse order from loading
110+
If (m_hLibWebPMux <> 0) Then
111+
VBHacks.FreeLib m_hLibWebPMux
112+
m_hLibWebPMux = 0
102113
End If
103114
If (m_hLibWebPDemux <> 0) Then
104115
VBHacks.FreeLib m_hLibWebPDemux
105116
m_hLibWebPDemux = 0
106117
End If
107-
If (m_hLibWebPMux <> 0) Then
108-
VBHacks.FreeLib m_hLibWebPMux
109-
m_hLibWebPMux = 0
118+
If (m_hLibWebP <> 0) Then
119+
VBHacks.FreeLib m_hLibWebP
120+
m_hLibWebP = 0
110121
End If
122+
If (m_hLibSharpYUV <> 0) Then
123+
VBHacks.FreeLib m_hLibSharpYUV
124+
m_hLibSharpYUV = 0
125+
End If
126+
111127
End Sub
112128

113129
'Import/Export/Validation functions follow

PhotoDemon.vbp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ Description="PhotoDemon Photo Editor"
518518
CompatibleMode="0"
519519
MajorVer=9
520520
MinorVer=1
521-
RevisionVer=163
521+
RevisionVer=164
522522
AutoIncrementVer=1
523523
ServerSupportFiles=0
524524
VersionComments="Copyright 2000-2023 Tanner Helland - photodemon.org"

0 commit comments

Comments
 (0)