Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
43ee4df3
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
43ee4df3
编写于
4月 18, 2011
作者:
R
Rich Felker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dns lookups: protect against cancellation and fix incorrect error codes
上级
75a0be1f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
4 deletion
+10
-4
src/network/__dns.c
src/network/__dns.c
+10
-4
未找到文件。
src/network/__dns.c
浏览文件 @
43ee4df3
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <time.h>
#include <time.h>
#include <ctype.h>
#include <ctype.h>
#include <unistd.h>
#include <unistd.h>
#include <pthread.h>
#include "__dns.h"
#include "__dns.h"
#include "stdio_impl.h"
#include "stdio_impl.h"
...
@@ -42,14 +43,15 @@ int __dns_doqueries(unsigned char *dest, const char *name, int *rr, int rrcnt)
...
@@ -42,14 +43,15 @@ int __dns_doqueries(unsigned char *dest, const char *name, int *rr, int rrcnt)
struct
timeval
tv
;
struct
timeval
tv
;
fd_set
fds
;
fd_set
fds
;
int
id
;
int
id
;
int
cs
;
/* Construct query template - RR and ID will be filled later */
/* Construct query template - RR and ID will be filled later */
if
(
strlen
(
name
)
-
1
>=
254U
)
return
-
1
;
if
(
strlen
(
name
)
-
1
>=
254U
)
return
EAI_NONAME
;
q
[
2
]
=
q
[
5
]
=
1
;
q
[
2
]
=
q
[
5
]
=
1
;
strcpy
((
char
*
)
q
+
13
,
name
);
strcpy
((
char
*
)
q
+
13
,
name
);
for
(
i
=
13
;
q
[
i
];
i
=
j
+
1
)
{
for
(
i
=
13
;
q
[
i
];
i
=
j
+
1
)
{
for
(
j
=
i
;
q
[
j
]
&&
q
[
j
]
!=
'.'
;
j
++
);
for
(
j
=
i
;
q
[
j
]
&&
q
[
j
]
!=
'.'
;
j
++
);
if
(
j
-
i
-
1u
>
62u
)
return
-
1
;
if
(
j
-
i
-
1u
>
62u
)
return
EAI_NONAME
;
q
[
i
-
1
]
=
j
-
i
;
q
[
i
-
1
]
=
j
-
i
;
}
}
q
[
i
+
3
]
=
1
;
q
[
i
+
3
]
=
1
;
...
@@ -80,12 +82,14 @@ int __dns_doqueries(unsigned char *dest, const char *name, int *rr, int rrcnt)
...
@@ -80,12 +82,14 @@ int __dns_doqueries(unsigned char *dest, const char *name, int *rr, int rrcnt)
sl
=
sizeof
sa
.
sin
;
sl
=
sizeof
sa
.
sin
;
}
}
pthread_setcancelstate
(
PTHREAD_CANCEL_DISABLE
,
&
cs
);
/* Get local address and open/bind a socket */
/* Get local address and open/bind a socket */
sa
.
sin
.
sin_family
=
family
;
sa
.
sin
.
sin_family
=
family
;
fd
=
socket
(
family
,
SOCK_DGRAM
,
0
);
fd
=
socket
(
family
,
SOCK_DGRAM
,
0
);
if
(
bind
(
fd
,
(
void
*
)
&
sa
,
sl
)
<
0
)
{
if
(
bind
(
fd
,
(
void
*
)
&
sa
,
sl
)
<
0
)
{
close
(
fd
)
;
errcode
=
EAI_SYSTEM
;
return
-
1
;
goto
out
;
}
}
/* Nonblocking to work around Linux UDP select bug */
/* Nonblocking to work around Linux UDP select bug */
fcntl
(
fd
,
F_SETFL
,
fcntl
(
fd
,
F_GETFL
,
0
)
|
O_NONBLOCK
);
fcntl
(
fd
,
F_SETFL
,
fcntl
(
fd
,
F_GETFL
,
0
)
|
O_NONBLOCK
);
...
@@ -140,7 +144,9 @@ int __dns_doqueries(unsigned char *dest, const char *name, int *rr, int rrcnt)
...
@@ -140,7 +144,9 @@ int __dns_doqueries(unsigned char *dest, const char *name, int *rr, int rrcnt)
/* Check to see if we have answers to all queries */
/* Check to see if we have answers to all queries */
if
(
got
+
failed
==
rrcnt
)
break
;
if
(
got
+
failed
==
rrcnt
)
break
;
}
}
out:
close
(
fd
);
close
(
fd
);
pthread_setcancelstate
(
cs
,
0
);
/* Return the number of results, or an error code if none */
/* Return the number of results, or an error code if none */
if
(
got
)
return
got
;
if
(
got
)
return
got
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录