Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
4948a24d
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
大约 1 年 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4948a24d
编写于
2月 01, 2012
作者:
R
Rich Felker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make passwd/group functions safe against cancellation in stdio
these changes are a prerequisite to making stdio cancellable.
上级
147f355c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
6 deletion
+35
-6
src/passwd/getgr_r.c
src/passwd/getgr_r.c
+10
-1
src/passwd/getgrent_a.c
src/passwd/getgrent_a.c
+7
-2
src/passwd/getpw_r.c
src/passwd/getpw_r.c
+10
-1
src/passwd/getpwent_a.c
src/passwd/getpwent_a.c
+8
-2
未找到文件。
src/passwd/getgr_r.c
浏览文件 @
4948a24d
#include "pwf.h"
#include <pthread.h>
#define FIX(x) (gr->gr_##x = gr->gr_##x-line+buf)
...
...
@@ -11,9 +12,15 @@ static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, siz
size_t
nmem
=
0
;
int
rv
=
0
;
size_t
i
;
int
cs
;
pthread_setcancelstate
(
PTHREAD_CANCEL_DISABLE
,
&
cs
);
f
=
fopen
(
"/etc/group"
,
"rb"
);
if
(
!
f
)
return
errno
;
if
(
!
f
)
{
rv
=
errno
;
goto
done
;
}
*
res
=
0
;
while
(
__getgrent_a
(
f
,
gr
,
&
line
,
&
len
,
&
mem
,
&
nmem
))
{
...
...
@@ -39,6 +46,8 @@ static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, siz
free
(
mem
);
free
(
line
);
fclose
(
f
);
done:
pthread_setcancelstate
(
cs
,
0
);
return
rv
;
}
...
...
src/passwd/getgrent_a.c
浏览文件 @
4948a24d
#include "pwf.h"
#include <pthread.h>
struct
group
*
__getgrent_a
(
FILE
*
f
,
struct
group
*
gr
,
char
**
line
,
size_t
*
size
,
char
***
mem
,
size_t
*
nmem
)
{
ssize_t
l
;
char
*
s
,
*
mems
;
size_t
i
;
int
cs
;
pthread_setcancelstate
(
PTHREAD_CANCEL_DISABLE
,
&
cs
);
for
(;;)
{
if
((
l
=
getline
(
line
,
size
,
f
))
<
0
)
{
free
(
*
line
);
*
line
=
0
;
return
0
;
gr
=
0
;
goto
end
;
}
line
[
0
][
l
-
1
]
=
0
;
...
...
@@ -46,5 +49,7 @@ struct group *__getgrent_a(FILE *f, struct group *gr, char **line, size_t *size,
mem
[
0
][
0
]
=
0
;
}
gr
->
gr_mem
=
*
mem
;
end:
pthread_setcancelstate
(
cs
,
0
);
return
gr
;
}
src/passwd/getpw_r.c
浏览文件 @
4948a24d
#include "pwf.h"
#include <pthread.h>
#define FIX(x) (pw->pw_##x = pw->pw_##x-line+buf)
...
...
@@ -8,9 +9,15 @@ static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, si
char
*
line
=
0
;
size_t
len
=
0
;
int
rv
=
0
;
int
cs
;
pthread_setcancelstate
(
PTHREAD_CANCEL_DISABLE
,
&
cs
);
f
=
fopen
(
"/etc/passwd"
,
"rb"
);
if
(
!
f
)
return
errno
;
if
(
!
f
)
{
rv
=
errno
;
goto
done
;
}
*
res
=
0
;
while
(
__getpwent_a
(
f
,
pw
,
&
line
,
&
len
))
{
...
...
@@ -32,6 +39,8 @@ static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, si
}
free
(
line
);
fclose
(
f
);
done:
pthread_setcancelstate
(
cs
,
0
);
return
rv
;
}
...
...
src/passwd/getpwent_a.c
浏览文件 @
4948a24d
#include "pwf.h"
#include <pthread.h>
struct
passwd
*
__getpwent_a
(
FILE
*
f
,
struct
passwd
*
pw
,
char
**
line
,
size_t
*
size
)
{
ssize_t
l
;
char
*
s
;
int
cs
;
pthread_setcancelstate
(
PTHREAD_CANCEL_DISABLE
,
&
cs
);
for
(;;)
{
if
((
l
=
getline
(
line
,
size
,
f
))
<
0
)
{
free
(
*
line
);
*
line
=
0
;
return
0
;
pw
=
0
;
break
;
}
line
[
0
][
l
-
1
]
=
0
;
...
...
@@ -32,6 +36,8 @@ struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *siz
if
(
!
(
s
=
strchr
(
s
,
':'
)))
continue
;
*
s
++
=
0
;
pw
->
pw_shell
=
s
;
return
pw
;
break
;
}
pthread_setcancelstate
(
cs
,
0
);
return
pw
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录