Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
2ca9aa16
Commit
2ca9aa16
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 'VDMX' data before using it.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f73ba331
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
36 deletions
+54
-36
dwrite_private.h
dlls/dwrite/dwrite_private.h
+2
-1
font.c
dlls/dwrite/font.c
+3
-2
opentype.c
dlls/dwrite/opentype.c
+49
-33
No files found.
dlls/dwrite/dwrite_private.h
View file @
2ca9aa16
...
...
@@ -229,7 +229,8 @@ extern HRESULT opentype_get_font_info_strings(const void*,DWRITE_INFORMATIONAL_S
extern
HRESULT
opentype_get_font_familyname
(
struct
file_stream_desc
*
,
IDWriteLocalizedStrings
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
opentype_get_font_facename
(
struct
file_stream_desc
*
,
WCHAR
*
,
IDWriteLocalizedStrings
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
opentype_get_typographic_features
(
IDWriteFontFace
*
,
UINT32
,
UINT32
,
UINT32
,
UINT32
*
,
DWRITE_FONT_FEATURE_TAG
*
)
DECLSPEC_HIDDEN
;
extern
BOOL
opentype_get_vdmx_size
(
const
void
*
,
INT
,
UINT16
*
,
UINT16
*
)
DECLSPEC_HIDDEN
;
extern
BOOL
opentype_get_vdmx_size
(
const
struct
dwrite_fonttable
*
table
,
INT
ppem
,
UINT16
*
ascent
,
UINT16
*
descent
)
DECLSPEC_HIDDEN
;
extern
unsigned
int
opentype_get_cpal_palettecount
(
const
struct
dwrite_fonttable
*
table
)
DECLSPEC_HIDDEN
;
extern
unsigned
int
opentype_get_cpal_paletteentrycount
(
const
struct
dwrite_fonttable
*
table
)
DECLSPEC_HIDDEN
;
extern
HRESULT
opentype_get_cpal_entries
(
const
struct
dwrite_fonttable
*
table
,
unsigned
int
palette
,
...
...
dlls/dwrite/font.c
View file @
2ca9aa16
...
...
@@ -374,9 +374,10 @@ static FLOAT get_font_prop_vec_dotproduct(const struct dwrite_font_propvec *left
return
left
->
stretch
*
right
->
stretch
+
left
->
style
*
right
->
style
+
left
->
weight
*
right
->
weight
;
}
static
const
void
*
get_fontface_vdmx
(
struct
dwrite_fontface
*
fontface
)
static
const
struct
dwrite_fonttable
*
get_fontface_vdmx
(
struct
dwrite_fontface
*
fontface
)
{
return
get_fontface_table
(
&
fontface
->
IDWriteFontFace4_iface
,
MS_VDMX_TAG
,
&
fontface
->
vdmx
);
get_fontface_table
(
&
fontface
->
IDWriteFontFace4_iface
,
MS_VDMX_TAG
,
&
fontface
->
vdmx
);
return
&
fontface
->
vdmx
;
}
static
const
struct
dwrite_fonttable
*
get_fontface_gasp
(
struct
dwrite_fontface
*
fontface
)
...
...
dlls/dwrite/opentype.c
View file @
2ca9aa16
...
...
@@ -343,14 +343,14 @@ typedef struct {
TT_NameRecord
nameRecord
[
1
];
}
TT_NAME_V0
;
struct
VDMX_H
eader
struct
vdmx_h
eader
{
WORD
version
;
WORD
num
R
ecs
;
WORD
num
R
atios
;
WORD
num
_r
ecs
;
WORD
num
_r
atios
;
};
struct
VDMX_R
atio
struct
vdmx_r
atio
{
BYTE
bCharSet
;
BYTE
xRatio
;
...
...
@@ -358,20 +358,21 @@ struct VDMX_Ratio
BYTE
yEndRatio
;
};
struct
VDMX_group
{
WORD
recs
;
BYTE
startsz
;
BYTE
endsz
;
};
struct
VDMX_vTable
struct
vdmx_vtable
{
WORD
yPelHeight
;
SHORT
yMax
;
SHORT
yMin
;
};
struct
vdmx_group
{
WORD
recs
;
BYTE
startsz
;
BYTE
endsz
;
struct
vdmx_vtable
entries
[
1
];
};
typedef
struct
{
CHAR
FeatureTag
[
4
];
WORD
Feature
;
...
...
@@ -1911,13 +1912,14 @@ HRESULT opentype_get_typographic_features(IDWriteFontFace *fontface, UINT32 scri
return
*
count
>
max_tagcount
?
E_NOT_SUFFICIENT_BUFFER
:
S_OK
;
}
static
const
struct
VDMX_group
*
find_vdmx_group
(
const
struct
VDMX_H
eader
*
hdr
)
static
unsigned
int
find_vdmx_group
(
const
struct
vdmx_h
eader
*
hdr
)
{
WORD
num_ratios
,
i
,
group_offset
=
0
;
struct
VDMX_Ratio
*
ratios
=
(
struct
VDMX_Ratio
*
)(
hdr
+
1
);
WORD
num_ratios
,
i
;
const
struct
vdmx_ratio
*
ratios
=
(
struct
vdmx_ratio
*
)(
hdr
+
1
);
BYTE
dev_x_ratio
=
1
,
dev_y_ratio
=
1
;
unsigned
int
group_offset
=
0
;
num_ratios
=
GET_BE_WORD
(
hdr
->
num
R
atios
);
num_ratios
=
GET_BE_WORD
(
hdr
->
num
_r
atios
);
for
(
i
=
0
;
i
<
num_ratios
;
i
++
)
{
...
...
@@ -1932,42 +1934,56 @@ static const struct VDMX_group *find_vdmx_group(const struct VDMX_Header *hdr)
break
;
}
}
if
(
group_offset
)
return
(
const
struct
VDMX_group
*
)((
BYTE
*
)
hdr
+
group_offset
);
return
NULL
;
return
group_offset
;
}
BOOL
opentype_get_vdmx_size
(
const
void
*
data
,
INT
emsize
,
UINT16
*
ascent
,
UINT16
*
descent
)
BOOL
opentype_get_vdmx_size
(
const
struct
dwrite_fonttable
*
vdmx
,
INT
emsize
,
UINT16
*
ascent
,
UINT16
*
descent
)
{
const
struct
VDMX_Header
*
hdr
=
(
const
struct
VDMX_Header
*
)
data
;
const
struct
VDMX_group
*
group
;
const
struct
VDMX_vTable
*
tables
;
WORD
recs
,
i
;
unsigned
int
num_ratios
,
num_recs
,
group_offset
,
i
;
const
struct
vdmx_header
*
header
;
const
struct
vdmx_group
*
group
;
if
(
!
vdmx
->
exists
)
return
FALSE
;
num_ratios
=
table_read_be_word
(
vdmx
,
FIELD_OFFSET
(
struct
vdmx_header
,
num_ratios
));
num_recs
=
table_read_be_word
(
vdmx
,
FIELD_OFFSET
(
struct
vdmx_header
,
num_recs
));
header
=
table_read_ensure
(
vdmx
,
0
,
sizeof
(
*
header
)
+
num_ratios
*
sizeof
(
struct
vdmx_ratio
)
+
num_recs
*
sizeof
(
*
group
));
if
(
!
header
)
return
FALSE
;
if
(
!
data
)
group_offset
=
find_vdmx_group
(
header
);
if
(
!
group_offset
)
return
FALSE
;
group
=
find_vdmx_group
(
hdr
);
num_recs
=
table_read_be_word
(
vdmx
,
group_offset
);
group
=
table_read_ensure
(
vdmx
,
group_offset
,
FIELD_OFFSET
(
struct
vdmx_group
,
entries
[
num_recs
]));
if
(
!
group
)
return
FALSE
;
recs
=
GET_BE_WORD
(
group
->
recs
);
if
(
emsize
<
group
->
startsz
||
emsize
>=
group
->
endsz
)
return
FALSE
;
if
(
emsize
<
group
->
startsz
||
emsize
>=
group
->
endsz
)
return
FALSE
;
tables
=
(
const
struct
VDMX_vTable
*
)(
group
+
1
);
for
(
i
=
0
;
i
<
recs
;
i
++
)
{
WORD
ppem
=
GET_BE_WORD
(
tabl
es
[
i
].
yPelHeight
);
for
(
i
=
0
;
i
<
num_recs
;
++
i
)
{
WORD
ppem
=
GET_BE_WORD
(
group
->
entri
es
[
i
].
yPelHeight
);
if
(
ppem
>
emsize
)
{
FIXME
(
"interpolate %d
\n
"
,
emsize
);
return
FALSE
;
}
if
(
ppem
==
emsize
)
{
*
ascent
=
(
SHORT
)
GET_BE_WORD
(
tabl
es
[
i
].
yMax
);
*
descent
=
-
(
SHORT
)
GET_BE_WORD
(
tabl
es
[
i
].
yMin
);
*
ascent
=
(
SHORT
)
GET_BE_WORD
(
group
->
entri
es
[
i
].
yMax
);
*
descent
=
-
(
SHORT
)
GET_BE_WORD
(
group
->
entri
es
[
i
].
yMin
);
return
TRUE
;
}
}
return
FALSE
;
}
...
...
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