Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
4ff2a589
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看板
提交
4ff2a589
编写于
8月 18, 2009
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bug 592194 - Fix missing _SC_PAGE_SIZE macro
Autoconfiscate a simple call to mprotect() even more.
上级
3c69bd46
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
34 deletion
+60
-34
src/hb-blob.c
src/hb-blob.c
+60
-34
未找到文件。
src/hb-blob.c
浏览文件 @
4ff2a589
...
...
@@ -234,6 +234,59 @@ hb_blob_is_writeable (hb_blob_t *blob)
return
mode
==
HB_MEMORY_MODE_WRITEABLE
;
}
static
hb_bool_t
_try_make_writeable_inplace_unix_locked
(
hb_blob_t
*
blob
)
{
#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT)
unsigned
int
pagesize
=
-
1
,
mask
,
length
;
const
char
*
addr
;
#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
pagesize
=
(
unsigned
int
)
sysconf
(
_SC_PAGE_SIZE
);
#elif defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
pagesize
=
(
unsigned
int
)
sysconf
(
_SC_PAGESIZE
);
#elif defined(HAVE_GETPAGESIZE)
pagesize
=
(
unsigned
int
)
getpagesize
();
#endif
if
((
unsigned
int
)
-
1
==
pagesize
)
{
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: failed to get pagesize: %s
\n
"
,
blob
,
__FUNCTION__
,
strerror
(
errno
));
#endif
return
FALSE
;
}
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: pagesize is %u
\n
"
,
blob
,
__FUNCTION__
,
pagesize
);
#endif
mask
=
~
(
pagesize
-
1
);
addr
=
(
const
char
*
)
(((
size_t
)
blob
->
data
)
&
mask
);
length
=
(
const
char
*
)
(((
size_t
)
blob
->
data
+
blob
->
length
+
pagesize
-
1
)
&
mask
)
-
addr
;
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: calling mprotect on [%p..%p] (%d bytes)
\n
"
,
blob
,
__FUNCTION__
,
addr
,
addr
+
length
,
length
);
#endif
if
(
-
1
==
mprotect
((
void
*
)
addr
,
length
,
PROT_READ
|
PROT_WRITE
))
{
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: %s
\n
"
,
blob
,
__FUNCTION__
,
strerror
(
errno
));
#endif
return
FALSE
;
}
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: successfully made [%p..%p] (%d bytes) writeable
\n
"
,
blob
,
__FUNCTION__
,
addr
,
addr
+
length
,
length
);
#endif
return
TRUE
;
#else
return
FALSE
;
#endif
}
hb_bool_t
hb_blob_try_writeable_inplace
(
hb_blob_t
*
blob
)
{
...
...
@@ -244,53 +297,26 @@ hb_blob_try_writeable_inplace (hb_blob_t *blob)
hb_mutex_lock
(
blob
->
lock
);
#ifdef HAVE_SYS_MMAN_H
if
(
blob
->
mode
==
HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITEABLE
)
{
unsigned
int
pagesize
,
mask
,
length
;
const
char
*
addr
;
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: making writeable
\n
"
,
blob
,
__FUNCTION__
);
#endif
pagesize
=
(
unsigned
int
)
sysconf
(
_SC_PAGE_SIZE
);
if
((
unsigned
int
)
-
1
==
pagesize
)
{
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: %s
\n
"
,
blob
,
__FUNCTION__
,
strerror
(
errno
));
#endif
goto
done
;
}
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: pagesize is %u
\n
"
,
blob
,
__FUNCTION__
,
pagesize
);
#endif
mask
=
~
(
pagesize
-
1
);
addr
=
(
const
char
*
)
(((
size_t
)
blob
->
data
)
&
mask
);
length
=
(
const
char
*
)
(((
size_t
)
blob
->
data
+
blob
->
length
+
pagesize
-
1
)
&
mask
)
-
addr
;
if
(
_try_make_writeable_inplace_unix_locked
(
blob
))
{
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: calling mprotect on [%p..%p] (%d bytes)
\n
"
,
blob
,
__FUNCTION__
,
addr
,
addr
+
length
,
length
);
fprintf
(
stderr
,
"%p %s: making writeable -> succeeded
\n
"
,
blob
,
__FUNCTION__
);
#endif
if
(
-
1
==
mprotect
((
void
*
)
addr
,
length
,
PROT_READ
|
PROT_WRITE
))
{
blob
->
mode
=
HB_MEMORY_MODE_WRITEABLE
;
}
else
{
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: %s
\n
"
,
blob
,
__FUNCTION__
,
strerror
(
errno
)
);
fprintf
(
stderr
,
"%p %s: making writeable -> FAILED
\n
"
,
blob
,
__FUNCTION__
);
#endif
goto
done
;
/* Failed to make writeable inplace, mark that */
blob
->
mode
=
HB_MEMORY_MODE_READONLY
;
}
blob
->
mode
=
HB_MEMORY_MODE_WRITEABLE
;
#if HB_DEBUG
fprintf
(
stderr
,
"%p %s: successfully made [%p..%p] (%d bytes) writeable
\n
"
,
blob
,
__FUNCTION__
,
addr
,
addr
+
length
,
length
);
#endif
}
#else
/* !HAVE_SYS_MMAN_H */
#warning "No way to make readonly memory writeable. This is suboptimal."
#endif
done:
mode
=
blob
->
mode
;
hb_mutex_unlock
(
blob
->
lock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录