Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
b508e5cc
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b508e5cc
编写于
8月 04, 2009
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[HB] open-file sanitize()
上级
738c54d9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
4 deletion
+55
-4
src/hb-open-file-private.hh
src/hb-open-file-private.hh
+42
-4
src/hb-open-types-private.hh
src/hb-open-types-private.hh
+13
-0
未找到文件。
src/hb-open-file-private.hh
浏览文件 @
b508e5cc
...
...
@@ -47,6 +47,11 @@ struct TTCHeader;
typedef
struct
TableDirectory
{
inline
bool
sanitize
(
SANITIZE_ARG_DEF
,
const
void
*
base
)
{
return
SANITIZE_SELF
()
&&
SANITIZE
(
tag
)
&&
SANITIZE_MEM
(
CONST_CHARP
(
base
)
+
(
unsigned
long
)
offset
,
length
);
}
Tag
tag
;
/* 4-byte identifier. */
CheckSum
checkSum
;
/* CheckSum for this table. */
ULONG
offset
;
/* Offset from beginning of TrueType font
...
...
@@ -60,13 +65,25 @@ typedef struct OffsetTable
friend
struct
OpenTypeFontFile
;
friend
struct
TTCHeader
;
STATIC_DEFINE_GET_FOR_DATA
(
OffsetTable
);
DEFINE_TAG_ARRAY_INTERFACE
(
OpenTypeTable
,
table
);
/* get_table_count(), get_table(i), get_table_tag(i) */
DEFINE_TAG_FIND_INTERFACE
(
OpenTypeTable
,
table
);
/* find_table_index(tag), get_table_by_tag(tag) */
unsigned
int
get_face_count
(
void
)
const
{
return
1
;
}
private:
/* OpenTypeTables, in no particular order */
DEFINE_ARRAY_TYPE
(
TableDirectory
,
tableDir
,
numTables
);
public:
inline
bool
sanitize
(
SANITIZE_ARG_DEF
,
const
void
*
base
)
{
if
(
!
(
SANITIZE_SELF
()
&&
SANITIZE_MEM
(
tableDir
,
sizeof
(
tableDir
[
0
])
*
numTables
)))
return
false
;
unsigned
int
count
=
numTables
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
!
SANITIZE_BASE
(
tableDir
[
i
],
base
))
return
false
;
}
private:
Tag
sfnt_version
;
/* '\0\001\0\00' if TrueType / 'OTTO' if CFF */
USHORT
numTables
;
/* Number of tables. */
...
...
@@ -87,6 +104,19 @@ struct TTCHeader
STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION
(
TTCHeader
,
1
,
2
);
unsigned
int
get_face_count
(
void
)
const
{
return
table
.
len
;
}
const
OpenTypeFontFace
&
get_face
(
unsigned
int
i
)
const
{
return
this
+
table
[
i
];
}
bool
sanitize
(
SANITIZE_ARG_DEF
)
{
if
(
!
SANITIZE
(
version
))
return
false
;
if
(
version
.
major
<
1
||
version
.
major
>
2
)
return
true
;
return
table
.
sanitize
(
SANITIZE_ARG
,
CONST_CHARP
(
this
),
CONST_CHARP
(
this
));
}
private:
Tag
ttcTag
;
/* TrueType Collection ID string: 'ttcf' */
FixedVersion
version
;
/* Version of the TTC Header (1.0 or 2.0),
...
...
@@ -114,8 +144,8 @@ struct OpenTypeFontFile
{
switch
(
tag
)
{
default:
return
0
;
case
TrueTypeTag
:
case
CFFTag
:
return
1
;
case
TTCTag
:
return
TTCHeader
::
get_for_data
(
CONST_CHARP
(
this
)).
table
.
len
;
case
TrueTypeTag
:
case
CFFTag
:
return
OffsetTable
::
get_for_data
(
CONST_CHARP
(
this
)).
get_face_count
()
;
case
TTCTag
:
return
TTCHeader
::
get_for_data
(
CONST_CHARP
(
this
)).
get_face_count
()
;
}
}
const
OpenTypeFontFace
&
get_face
(
unsigned
int
i
)
const
...
...
@@ -125,8 +155,8 @@ struct OpenTypeFontFile
/* Note: for non-collection SFNT data we ignore index. This is because
* Apple dfont container is a container of SFNT's. So each SFNT is a
* non-TTC, but the index is more than zero. */
case
TrueTypeTag
:
case
CFFTag
:
return
*
(
const
OffsetTable
*
)
this
;
case
TTCTag
:
return
this
+
TTCHeader
::
get_for_data
(
CONST_CHARP
(
this
)).
table
[
i
]
;
case
TrueTypeTag
:
case
CFFTag
:
return
OffsetTable
::
get_for_data
(
CONST_CHARP
(
this
))
;
case
TTCTag
:
return
TTCHeader
::
get_for_data
(
CONST_CHARP
(
this
)).
get_face
(
i
)
;
}
}
...
...
@@ -137,6 +167,14 @@ struct OpenTypeFontFile
return
((
const
char
*
)
this
)
+
table
.
offset
;
}
bool
sanitize
(
SANITIZE_ARG_DEF
)
{
switch
(
tag
)
{
default:
return
true
;
case
TrueTypeTag
:
case
CFFTag
:
return
SANITIZE_THIS
(
CAST
(
OffsetTable
,
*
this
,
0
));
case
TTCTag
:
return
SANITIZE
(
CAST
(
TTCHeader
,
*
this
,
0
));
}
}
Tag
tag
;
/* 4-byte identifier. */
};
ASSERT_SIZE
(
OpenTypeFontFile
,
4
);
...
...
src/hb-open-types-private.hh
浏览文件 @
b508e5cc
...
...
@@ -362,6 +362,12 @@ struct GenericOffsetTo : OffsetType
if
(
HB_UNLIKELY
(
!
offset
))
return
true
;
return
SANITIZE
(
CAST
(
Type
,
*
DECONST_CHARP
(
base
),
offset
))
||
NEUTER
(
DECONST_CAST
(
OffsetType
,
*
this
,
0
),
0
);
}
inline
bool
sanitize
(
SANITIZE_ARG_DEF
,
const
void
*
base
,
const
void
*
base2
)
{
if
(
!
SANITIZE_OBJ
(
*
this
))
return
false
;
unsigned
int
offset
=
*
this
;
if
(
HB_UNLIKELY
(
!
offset
))
return
true
;
return
SANITIZE_BASE
(
CAST
(
Type
,
*
DECONST_CHARP
(
base
),
offset
),
base2
)
||
NEUTER
(
DECONST_CAST
(
OffsetType
,
*
this
,
0
),
0
);
}
inline
bool
sanitize
(
SANITIZE_ARG_DEF
,
const
void
*
base
,
unsigned
int
user_data
)
{
if
(
!
SANITIZE_OBJ
(
*
this
))
return
false
;
unsigned
int
offset
=
*
this
;
...
...
@@ -408,6 +414,13 @@ struct GenericArrayOf
if
(
!
array
[
i
].
sanitize
(
SANITIZE_ARG
,
base
))
return
false
;
}
inline
bool
sanitize
(
SANITIZE_ARG_DEF
,
const
void
*
base
,
const
void
*
base2
)
{
if
(
!
SANITIZE_GET_SIZE
())
return
false
;
unsigned
int
count
=
len
;
for
(
unsigned
int
i
=
0
;
i
<
count
;
i
++
)
if
(
!
array
[
i
].
sanitize
(
SANITIZE_ARG
,
base
,
base2
))
return
false
;
}
inline
bool
sanitize
(
SANITIZE_ARG_DEF
,
const
void
*
base
,
unsigned
int
user_data
)
{
if
(
!
SANITIZE_GET_SIZE
())
return
false
;
unsigned
int
count
=
len
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录