Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e6967c51
Commit
e6967c51
authored
Jan 29, 2019
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jan 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Validate 'CBLC' data before using it.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1ee96850
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
31 deletions
+39
-31
dwrite_private.h
dlls/dwrite/dwrite_private.h
+3
-0
font.c
dlls/dwrite/font.c
+1
-1
opentype.c
dlls/dwrite/opentype.c
+34
-29
font.c
dlls/dwrite/tests/font.c
+1
-1
No files found.
dlls/dwrite/dwrite_private.h
View file @
e6967c51
...
...
@@ -216,6 +216,9 @@ struct dwrite_fonttable
BOOL
exists
;
};
extern
const
void
*
get_fontface_table
(
IDWriteFontFace4
*
fontface
,
UINT32
tag
,
struct
dwrite_fonttable
*
table
)
DECLSPEC_HIDDEN
;
extern
HRESULT
opentype_analyze_font
(
IDWriteFontFileStream
*
,
BOOL
*
,
DWRITE_FONT_FILE_TYPE
*
,
DWRITE_FONT_FACE_TYPE
*
,
UINT32
*
)
DECLSPEC_HIDDEN
;
extern
HRESULT
opentype_get_font_table
(
struct
file_stream_desc
*
,
UINT32
,
const
void
**
,
void
**
,
UINT32
*
,
BOOL
*
)
DECLSPEC_HIDDEN
;
extern
HRESULT
opentype_cmap_get_unicode_ranges
(
const
struct
dwrite_fonttable
*
table
,
unsigned
int
max_count
,
...
...
dlls/dwrite/font.c
View file @
e6967c51
...
...
@@ -338,7 +338,7 @@ static HRESULT set_cached_glyph_metrics(struct dwrite_fontface *fontface, UINT16
return
S_OK
;
}
static
const
void
*
get_fontface_table
(
IDWriteFontFace4
*
fontface
,
UINT32
tag
,
struct
dwrite_fonttable
*
table
)
const
void
*
get_fontface_table
(
IDWriteFontFace4
*
fontface
,
UINT32
tag
,
struct
dwrite_fonttable
*
table
)
{
HRESULT
hr
;
...
...
dlls/dwrite/opentype.c
View file @
e6967c51
...
...
@@ -268,17 +268,19 @@ typedef struct {
WORD
numGlyphs
;
}
maxp
;
typedef
struct
{
WORD
majorVersion
;
WORD
minorVersion
;
DWORD
numSizes
;
}
CBLCHeader
;
struct
cblc_header
{
WORD
major_version
;
WORD
minor_version
;
DWORD
num_sizes
;
};
typedef
struct
{
BYTE
res
[
12
];
}
sbitLineMetrics
;
typedef
struct
{
struct
cblc_bitmapsize_table
{
DWORD
indexSubTableArrayOffset
;
DWORD
indexTablesSize
;
DWORD
numberofIndexSubTables
;
...
...
@@ -289,9 +291,9 @@ typedef struct {
WORD
endGlyphIndex
;
BYTE
ppemX
;
BYTE
ppemY
;
BYTE
bit
D
epth
;
BYTE
bit
_d
epth
;
BYTE
flags
;
}
CBLCBitmapSizeTable
;
};
struct
gasp_range
{
...
...
@@ -2284,36 +2286,39 @@ static DWORD opentype_get_sbix_formats(IDWriteFontFace4 *fontface)
return
ret
;
}
static
UINT32
opentype_get_cblc_formats
(
IDWriteFontFace4
*
fontface
)
static
unsigned
int
opentype_get_cblc_formats
(
IDWriteFontFace4
*
fontface
)
{
CBLCBitmapSizeTable
*
sizes
;
UINT32
num_sizes
,
size
,
s
;
BOOL
exists
=
FALSE
;
CBLCHeader
*
header
;
UINT32
ret
=
0
;
void
*
context
;
HRESULT
hr
;
const
unsigned
int
format_mask
=
DWRITE_GLYPH_IMAGE_FORMATS_PNG
|
DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8
;
const
struct
cblc_bitmapsize_table
*
sizes
;
struct
dwrite_fonttable
cblc
=
{
0
};
unsigned
int
num_sizes
,
i
,
ret
=
0
;
const
struct
cblc_header
*
header
;
if
(
FAILED
(
hr
=
IDWriteFontFace4_TryGetFontTable
(
fontface
,
MS_CBLC_TAG
,
(
const
void
**
)
&
header
,
&
size
,
&
context
,
&
exists
)
))
cblc
.
exists
=
TRUE
;
if
(
!
get_fontface_table
(
fontface
,
MS_CBLC_TAG
,
&
cblc
))
return
0
;
if
(
!
exists
)
return
0
;
num_sizes
=
table_read_be_dword
(
&
cblc
,
FIELD_OFFSET
(
struct
cblc_header
,
num_sizes
));
sizes
=
table_read_ensure
(
&
cblc
,
sizeof
(
*
header
),
num_sizes
*
sizeof
(
*
sizes
))
;
num_sizes
=
GET_BE_DWORD
(
header
->
numSizes
);
sizes
=
(
CBLCBitmapSizeTable
*
)(
header
+
1
);
if
(
sizes
)
{
for
(
i
=
0
;
i
<
num_sizes
;
++
i
)
{
BYTE
bpp
=
sizes
[
i
].
bit_depth
;
for
(
s
=
0
;
s
<
num_sizes
;
s
++
)
{
BYTE
bpp
=
sizes
->
bitDepth
;
if
((
ret
&
format_mask
)
==
format_mask
)
break
;
if
(
bpp
==
1
||
bpp
==
2
||
bpp
==
4
||
bpp
==
8
)
ret
|=
DWRITE_GLYPH_IMAGE_FORMATS_PNG
;
else
if
(
bpp
==
32
)
ret
|=
DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8
;
if
(
bpp
==
1
||
bpp
==
2
||
bpp
==
4
||
bpp
==
8
)
ret
|=
DWRITE_GLYPH_IMAGE_FORMATS_PNG
;
else
if
(
bpp
==
32
)
ret
|=
DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8
;
}
}
IDWriteFontFace4_ReleaseFontTable
(
fontface
,
context
);
IDWriteFontFace4_ReleaseFontTable
(
fontface
,
c
blc
.
c
ontext
);
return
ret
;
}
...
...
dlls/dwrite/tests/font.c
View file @
e6967c51
...
...
@@ -8755,7 +8755,7 @@ static DWORD get_cblc_formats(IDWriteFontFace4 *fontface)
sizes
=
(
CBLCBitmapSizeTable
*
)(
header
+
1
);
for
(
s
=
0
;
s
<
num_sizes
;
s
++
)
{
BYTE
bpp
=
sizes
->
bitDepth
;
BYTE
bpp
=
sizes
[
s
].
bitDepth
;
if
(
bpp
==
1
||
bpp
==
2
||
bpp
==
4
||
bpp
==
8
)
ret
|=
DWRITE_GLYPH_IMAGE_FORMATS_PNG
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment