Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
ff50bdfd
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ff50bdfd
编写于
7月 04, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_ALLOC and virAsprintf in src/rpc/*
上级
7be0e3c9
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
60 addition
and
153 deletion
+60
-153
src/rpc/gendispatch.pl
src/rpc/gendispatch.pl
+2
-6
src/rpc/virnetclient.c
src/rpc/virnetclient.c
+8
-18
src/rpc/virnetclientprogram.c
src/rpc/virnetclientprogram.c
+3
-9
src/rpc/virnetclientstream.c
src/rpc/virnetclientstream.c
+1
-3
src/rpc/virnetmessage.c
src/rpc/virnetmessage.c
+7
-19
src/rpc/virnetserver.c
src/rpc/virnetserver.c
+7
-16
src/rpc/virnetserverclient.c
src/rpc/virnetserverclient.c
+4
-15
src/rpc/virnetservermdns.c
src/rpc/virnetservermdns.c
+5
-15
src/rpc/virnetserverprogram.c
src/rpc/virnetserverprogram.c
+2
-6
src/rpc/virnetserverservice.c
src/rpc/virnetserverservice.c
+3
-9
src/rpc/virnetsocket.c
src/rpc/virnetsocket.c
+2
-6
src/rpc/virnetsshsession.c
src/rpc/virnetsshsession.c
+5
-16
src/rpc/virnettlscontext.c
src/rpc/virnettlscontext.c
+11
-15
未找到文件。
src/rpc/gendispatch.pl
浏览文件 @
ff50bdfd
...
...
@@ -661,10 +661,8 @@ elsif ($mode eq "server") {
push
(
@free_list
,
"
VIR_FREE($1);
");
push
(
@free_list_on_error
,
"
VIR_FREE($1_p);
");
push
(
@prepare_ret_list
,
"
if (VIR_ALLOC($1_p) < 0) {
\n
"
.
"
virReportOOMError();
\n
"
.
"
if (VIR_ALLOC($1_p) < 0)
\n
"
.
"
goto cleanup;
\n
"
.
"
}
\n
"
.
"
\n
"
.
"
if (VIR_STRDUP(*$1_p, $1) < 0)
\n
"
.
"
goto cleanup;
\n
");
...
...
@@ -932,10 +930,8 @@ elsif ($mode eq "server") {
if
(
$single_ret_as_list
)
{
print
"
/* Allocate return buffer. */
\n
";
print
"
if (VIR_ALLOC_N(ret->
$single_ret_list_name
.
${single_ret_list_name}
_val,
"
.
"
args->
$single_ret_list_max_var
) < 0) {
\n
";
print
"
virReportOOMError();
\n
";
"
args->
$single_ret_list_max_var
) < 0)
\n
";
print
"
goto cleanup;
\n
";
print
"
}
\n
";
print
"
\n
";
}
...
...
src/rpc/virnetclient.c
浏览文件 @
ff50bdfd
...
...
@@ -875,15 +875,14 @@ int virNetClientAddProgram(virNetClientPtr client,
virObjectLock
(
client
);
if
(
VIR_EXPAND_N
(
client
->
programs
,
client
->
nprograms
,
1
)
<
0
)
goto
no_memory
;
goto
error
;
client
->
programs
[
client
->
nprograms
-
1
]
=
virObjectRef
(
prog
);
virObjectUnlock
(
client
);
return
0
;
no_memory:
virReportOOMError
();
error:
virObjectUnlock
(
client
);
return
-
1
;
}
...
...
@@ -895,15 +894,14 @@ int virNetClientAddStream(virNetClientPtr client,
virObjectLock
(
client
);
if
(
VIR_EXPAND_N
(
client
->
streams
,
client
->
nstreams
,
1
)
<
0
)
goto
no_memory
;
goto
error
;
client
->
streams
[
client
->
nstreams
-
1
]
=
virObjectRef
(
st
);
virObjectUnlock
(
client
);
return
0
;
no_memory:
virReportOOMError
();
error:
virObjectUnlock
(
client
);
return
-
1
;
}
...
...
@@ -981,10 +979,8 @@ virNetClientCallDispatchReply(virNetClientPtr client)
return
-
1
;
}
if
(
VIR_REALLOC_N
(
thecall
->
msg
->
buffer
,
client
->
msg
.
bufferLength
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
thecall
->
msg
->
buffer
,
client
->
msg
.
bufferLength
)
<
0
)
return
-
1
;
}
memcpy
(
thecall
->
msg
->
buffer
,
client
->
msg
.
buffer
,
client
->
msg
.
bufferLength
);
memcpy
(
&
thecall
->
msg
->
header
,
&
client
->
msg
.
header
,
sizeof
(
client
->
msg
.
header
));
...
...
@@ -1233,10 +1229,8 @@ virNetClientIOReadMessage(virNetClientPtr client)
/* Start by reading length word */
if
(
client
->
msg
.
bufferLength
==
0
)
{
client
->
msg
.
bufferLength
=
4
;
if
(
VIR_ALLOC_N
(
client
->
msg
.
buffer
,
client
->
msg
.
bufferLength
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
client
->
msg
.
buffer
,
client
->
msg
.
bufferLength
)
<
0
)
return
-
ENOMEM
;
}
}
wantData
=
client
->
msg
.
bufferLength
-
client
->
msg
.
bufferOffset
;
...
...
@@ -1888,10 +1882,8 @@ virNetClientCallNew(virNetMessagePtr msg,
goto
error
;
}
if
(
VIR_ALLOC
(
call
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
call
)
<
0
)
goto
error
;
}
if
(
virCondInit
(
&
call
->
cond
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
...
...
@@ -1964,10 +1956,8 @@ static int virNetClientSendInternal(virNetClientPtr client,
return
-
1
;
}
if
(
!
(
call
=
virNetClientCallNew
(
msg
,
expectReply
,
nonBlock
)))
{
virReportOOMError
();
if
(
!
(
call
=
virNetClientCallNew
(
msg
,
expectReply
,
nonBlock
)))
return
-
1
;
}
call
->
haveThread
=
true
;
ret
=
virNetClientIO
(
client
,
call
);
...
...
src/rpc/virnetclientprogram.c
浏览文件 @
ff50bdfd
...
...
@@ -250,10 +250,8 @@ int virNetClientProgramDispatch(virNetClientProgramPtr prog,
return
-
1
;
}
if
(
VIR_ALLOC_N
(
evdata
,
event
->
msg_len
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
evdata
,
event
->
msg_len
)
<
0
)
return
-
1
;
}
if
(
virNetMessageDecodePayload
(
msg
,
event
->
msg_filter
,
evdata
)
<
0
)
goto
cleanup
;
...
...
@@ -297,10 +295,8 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
msg
->
header
.
serial
=
serial
;
msg
->
header
.
proc
=
proc
;
msg
->
nfds
=
noutfds
;
if
(
VIR_ALLOC_N
(
msg
->
fds
,
msg
->
nfds
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
msg
->
fds
,
msg
->
nfds
)
<
0
)
goto
error
;
}
for
(
i
=
0
;
i
<
msg
->
nfds
;
i
++
)
msg
->
fds
[
i
]
=
-
1
;
for
(
i
=
0
;
i
<
msg
->
nfds
;
i
++
)
{
...
...
@@ -358,10 +354,8 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
case
VIR_NET_OK
:
if
(
infds
&&
ninfds
)
{
*
ninfds
=
msg
->
nfds
;
if
(
VIR_ALLOC_N
(
*
infds
,
*
ninfds
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
*
infds
,
*
ninfds
)
<
0
)
goto
error
;
}
for
(
i
=
0
;
i
<
*
ninfds
;
i
++
)
(
*
infds
)[
i
]
=
-
1
;
for
(
i
=
0
;
i
<
*
ninfds
;
i
++
)
{
...
...
src/rpc/virnetclientstream.c
浏览文件 @
ff50bdfd
...
...
@@ -373,10 +373,8 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
goto
cleanup
;
}
if
(
!
(
msg
=
virNetMessageNew
(
false
)))
{
virReportOOMError
();
if
(
!
(
msg
=
virNetMessageNew
(
false
)))
goto
cleanup
;
}
msg
->
header
.
prog
=
virNetClientProgramGetProgram
(
st
->
prog
);
msg
->
header
.
vers
=
virNetClientProgramGetVersion
(
st
->
prog
);
...
...
src/rpc/virnetmessage.c
浏览文件 @
ff50bdfd
...
...
@@ -37,10 +37,8 @@ virNetMessagePtr virNetMessageNew(bool tracked)
{
virNetMessagePtr
msg
;
if
(
VIR_ALLOC
(
msg
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
msg
)
<
0
)
return
NULL
;
}
msg
->
tracked
=
tracked
;
VIR_DEBUG
(
"msg=%p tracked=%d"
,
msg
,
tracked
);
...
...
@@ -144,10 +142,8 @@ int virNetMessageDecodeLength(virNetMessagePtr msg)
/* Extend our declared buffer length and carry
on reading the header + payload */
msg
->
bufferLength
+=
len
;
if
(
VIR_REALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
goto
cleanup
;
}
VIR_DEBUG
(
"Got length, now need %zu total (%u more)"
,
msg
->
bufferLength
,
len
);
...
...
@@ -223,10 +219,8 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
unsigned
int
len
=
0
;
msg
->
bufferLength
=
VIR_NET_MESSAGE_INITIAL
+
VIR_NET_MESSAGE_LEN_MAX
;
if
(
VIR_REALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
return
ret
;
}
msg
->
bufferOffset
=
0
;
/* Format the header. */
...
...
@@ -322,10 +316,8 @@ int virNetMessageDecodeNumFDs(virNetMessagePtr msg)
}
msg
->
nfds
=
numFDs
;
if
(
VIR_ALLOC_N
(
msg
->
fds
,
msg
->
nfds
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
msg
->
fds
,
msg
->
nfds
)
<
0
)
goto
cleanup
;
}
for
(
i
=
0
;
i
<
msg
->
nfds
;
i
++
)
msg
->
fds
[
i
]
=
-
1
;
...
...
@@ -364,10 +356,8 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
msg
->
bufferLength
=
(
msg
->
bufferLength
-
VIR_NET_MESSAGE_LEN_MAX
)
*
4
+
VIR_NET_MESSAGE_LEN_MAX
;
if
(
VIR_REALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
goto
error
;
}
xdrmem_create
(
&
xdr
,
msg
->
buffer
+
msg
->
bufferOffset
,
msg
->
bufferLength
-
msg
->
bufferOffset
,
XDR_ENCODE
);
...
...
@@ -445,10 +435,8 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
msg
->
bufferLength
=
msg
->
bufferOffset
+
len
;
if
(
VIR_REALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
return
-
1
;
}
VIR_DEBUG
(
"Increased message buffer length = %zu"
,
msg
->
bufferLength
);
}
...
...
@@ -533,7 +521,7 @@ void virNetMessageSaveError(virNetMessageErrorPtr rerr)
}
else
{
rerr
->
code
=
VIR_ERR_INTERNAL_ERROR
;
rerr
->
domain
=
VIR_FROM_RPC
;
if
(
VIR_ALLOC
(
rerr
->
message
)
==
0
&&
if
(
VIR_ALLOC
_QUIET
(
rerr
->
message
)
==
0
&&
VIR_STRDUP_QUIET
(
*
rerr
->
message
,
_
(
"Library function returned error but did not set virError"
))
<
0
)
VIR_FREE
(
rerr
->
message
);
...
...
src/rpc/virnetserver.c
浏览文件 @
ff50bdfd
...
...
@@ -221,10 +221,8 @@ static int virNetServerDispatchNewMessage(virNetServerClientPtr client,
if
(
srv
->
workers
)
{
virNetServerJobPtr
job
;
if
(
VIR_ALLOC
(
job
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
job
)
<
0
)
goto
cleanup
;
}
job
->
client
=
client
;
job
->
msg
=
msg
;
...
...
@@ -267,10 +265,8 @@ static int virNetServerAddClient(virNetServerPtr srv,
if
(
virNetServerClientInit
(
client
)
<
0
)
goto
error
;
if
(
VIR_EXPAND_N
(
srv
->
clients
,
srv
->
nclients
,
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_EXPAND_N
(
srv
->
clients
,
srv
->
nclients
,
1
)
<
0
)
goto
error
;
}
srv
->
clients
[
srv
->
nclients
-
1
]
=
client
;
virObjectRef
(
client
);
...
...
@@ -933,10 +929,10 @@ int virNetServerAddSignalHandler(virNetServerPtr srv,
goto
error
;
if
(
VIR_EXPAND_N
(
srv
->
signals
,
srv
->
nsignals
,
1
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
VIR_ALLOC
(
sigdata
)
<
0
)
goto
no_memory
;
goto
error
;
sigdata
->
signum
=
signum
;
sigdata
->
func
=
func
;
...
...
@@ -954,8 +950,6 @@ int virNetServerAddSignalHandler(virNetServerPtr srv,
virObjectUnlock
(
srv
);
return
0
;
no_memory:
virReportOOMError
();
error:
VIR_FREE
(
sigdata
);
virObjectUnlock
(
srv
);
...
...
@@ -971,7 +965,7 @@ int virNetServerAddService(virNetServerPtr srv,
virObjectLock
(
srv
);
if
(
VIR_EXPAND_N
(
srv
->
services
,
srv
->
nservices
,
1
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
mdnsEntryName
)
{
int
port
=
virNetServerServiceGetPort
(
svc
);
...
...
@@ -992,8 +986,6 @@ int virNetServerAddService(virNetServerPtr srv,
virObjectUnlock
(
srv
);
return
0
;
no_memory:
virReportOOMError
();
error:
virObjectUnlock
(
srv
);
return
-
1
;
...
...
@@ -1005,15 +997,14 @@ int virNetServerAddProgram(virNetServerPtr srv,
virObjectLock
(
srv
);
if
(
VIR_EXPAND_N
(
srv
->
programs
,
srv
->
nprograms
,
1
)
<
0
)
goto
no_memory
;
goto
error
;
srv
->
programs
[
srv
->
nprograms
-
1
]
=
virObjectRef
(
prog
);
virObjectUnlock
(
srv
);
return
0
;
no_memory:
virReportOOMError
();
error:
virObjectUnlock
(
srv
);
return
-
1
;
}
...
...
src/rpc/virnetserverclient.c
浏览文件 @
ff50bdfd
...
...
@@ -241,10 +241,8 @@ int virNetServerClientAddFilter(virNetServerClientPtr client,
virNetServerClientFilterPtr
*
place
;
int
ret
;
if
(
VIR_ALLOC
(
filter
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
filter
)
<
0
)
return
-
1
;
}
virObjectLock
(
client
);
...
...
@@ -316,7 +314,6 @@ virNetServerClientCheckAccess(virNetServerClientPtr client)
*/
confirm
->
bufferLength
=
1
;
if
(
VIR_ALLOC_N
(
confirm
->
buffer
,
confirm
->
bufferLength
)
<
0
)
{
virReportOOMError
();
virNetMessageFree
(
confirm
);
return
-
1
;
}
...
...
@@ -378,10 +375,8 @@ virNetServerClientNewInternal(virNetSocketPtr sock,
if
(
!
(
client
->
rx
=
virNetMessageNew
(
true
)))
goto
error
;
client
->
rx
->
bufferLength
=
VIR_NET_MESSAGE_LEN_MAX
;
if
(
VIR_ALLOC_N
(
client
->
rx
->
buffer
,
client
->
rx
->
bufferLength
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
client
->
rx
->
buffer
,
client
->
rx
->
bufferLength
)
<
0
)
goto
error
;
}
client
->
nrequests
=
1
;
PROBE
(
RPC_SERVER_CLIENT_NEW
,
...
...
@@ -680,15 +675,11 @@ virNetServerClientCreateIdentity(virNetServerClientPtr client)
if
(
!
(
groupname
=
virGetGroupName
(
gid
)))
goto
cleanup
;
if
(
virAsprintf
(
&
processid
,
"%llu"
,
(
unsigned
long
long
)
pid
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
pid
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
processtime
,
"%llu"
,
timestamp
)
<
0
)
{
virReportOOMError
();
timestamp
)
<
0
)
goto
cleanup
;
}
}
#if WITH_SASL
...
...
@@ -1243,7 +1234,6 @@ readmore:
client
->
rx
->
bufferLength
=
VIR_NET_MESSAGE_LEN_MAX
;
if
(
VIR_ALLOC_N
(
client
->
rx
->
buffer
,
client
->
rx
->
bufferLength
)
<
0
)
{
virReportOOMError
();
client
->
wantClose
=
true
;
}
else
{
client
->
nrequests
++
;
...
...
@@ -1346,7 +1336,6 @@ virNetServerClientDispatchWrite(virNetServerClientPtr client)
virNetMessageClear
(
msg
);
msg
->
bufferLength
=
VIR_NET_MESSAGE_LEN_MAX
;
if
(
VIR_ALLOC_N
(
msg
->
buffer
,
msg
->
bufferLength
)
<
0
)
{
virReportOOMError
();
virNetMessageFree
(
msg
);
return
;
}
...
...
src/rpc/virnetservermdns.c
浏览文件 @
ff50bdfd
...
...
@@ -273,10 +273,8 @@ static AvahiWatch *virNetServerMDNSWatchNew(const AvahiPoll *api ATTRIBUTE_UNUSE
{
AvahiWatch
*
w
;
virEventHandleType
hEvents
;
if
(
VIR_ALLOC
(
w
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
w
)
<
0
)
return
NULL
;
}
w
->
fd
=
fd
;
w
->
revents
=
0
;
...
...
@@ -338,10 +336,8 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U
struct
timeval
now
;
long
long
nowms
,
thenms
,
timeout
;
VIR_DEBUG
(
"Add timeout TV %p"
,
tv
);
if
(
VIR_ALLOC
(
t
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
t
)
<
0
)
return
NULL
;
}
if
(
gettimeofday
(
&
now
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
...
...
@@ -413,10 +409,8 @@ static void virNetServerMDNSTimeoutFree(AvahiTimeout *t)
static
AvahiPoll
*
virNetServerMDNSCreatePoll
(
void
)
{
AvahiPoll
*
p
;
if
(
VIR_ALLOC
(
p
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
p
)
<
0
)
return
NULL
;
}
p
->
userdata
=
NULL
;
...
...
@@ -475,10 +469,8 @@ virNetServerMDNSGroupPtr virNetServerMDNSAddGroup(virNetServerMDNS *mdns,
virNetServerMDNSGroupPtr
group
;
VIR_DEBUG
(
"Adding group '%s'"
,
name
);
if
(
VIR_ALLOC
(
group
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
group
)
<
0
)
return
NULL
;
}
if
(
VIR_STRDUP
(
group
->
name
,
name
)
<
0
)
{
VIR_FREE
(
group
);
...
...
@@ -519,10 +511,8 @@ virNetServerMDNSEntryPtr virNetServerMDNSAddEntry(virNetServerMDNSGroupPtr group
virNetServerMDNSEntryPtr
entry
;
VIR_DEBUG
(
"Adding entry %s %d to group %s"
,
type
,
port
,
group
->
name
);
if
(
VIR_ALLOC
(
entry
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
entry
)
<
0
)
return
NULL
;
}
entry
->
port
=
port
;
if
(
VIR_STRDUP
(
entry
->
type
,
type
)
<
0
)
{
...
...
src/rpc/virnetserverprogram.c
浏览文件 @
ff50bdfd
...
...
@@ -408,14 +408,10 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
goto
error
;
}
if
(
VIR_ALLOC_N
(
arg
,
dispatcher
->
arg_len
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
arg
,
dispatcher
->
arg_len
)
<
0
)
goto
error
;
}
if
(
VIR_ALLOC_N
(
ret
,
dispatcher
->
ret_len
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
ret
,
dispatcher
->
ret_len
)
<
0
)
goto
error
;
}
if
(
virNetMessageDecodePayload
(
msg
,
dispatcher
->
arg_filter
,
arg
)
<
0
)
goto
error
;
...
...
src/rpc/virnetserverservice.c
浏览文件 @
ff50bdfd
...
...
@@ -175,7 +175,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
svc
->
nsocks
=
1
;
if
(
VIR_ALLOC_N
(
svc
->
socks
,
svc
->
nsocks
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
virNetSocketNewListenUNIX
(
path
,
mask
,
...
...
@@ -204,8 +204,6 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
return
svc
;
no_memory:
virReportOOMError
();
error:
virObjectUnref
(
svc
);
return
NULL
;
...
...
@@ -237,7 +235,7 @@ virNetServerServicePtr virNetServerServiceNewFD(int fd,
svc
->
nsocks
=
1
;
if
(
VIR_ALLOC_N
(
svc
->
socks
,
svc
->
nsocks
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
virNetSocketNewListenFD
(
fd
,
&
svc
->
socks
[
0
])
<
0
)
...
...
@@ -257,8 +255,6 @@ virNetServerServicePtr virNetServerServiceNewFD(int fd,
return
svc
;
no_memory:
virReportOOMError
();
error:
virObjectUnref
(
svc
);
return
NULL
;
...
...
@@ -310,10 +306,8 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
}
svc
->
nsocks
=
n
;
if
(
VIR_ALLOC_N
(
svc
->
socks
,
svc
->
nsocks
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
svc
->
socks
,
svc
->
nsocks
)
<
0
)
goto
error
;
}
for
(
i
=
0
;
i
<
svc
->
nsocks
;
i
++
)
{
virJSONValuePtr
child
=
virJSONValueArrayGet
(
socks
,
i
);
...
...
src/rpc/virnetsocket.c
浏览文件 @
ff50bdfd
...
...
@@ -297,10 +297,8 @@ int virNetSocketNewListenTCP(const char *nodename,
VIR_DEBUG
(
"%p f=%d f=%d"
,
&
addr
,
runp
->
ai_family
,
addr
.
data
.
sa
.
sa_family
);
if
(
VIR_EXPAND_N
(
socks
,
nsocks
,
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_EXPAND_N
(
socks
,
nsocks
,
1
)
<
0
)
goto
error
;
}
if
(
!
(
socks
[
nsocks
-
1
]
=
virNetSocketNew
(
&
addr
,
NULL
,
false
,
fd
,
-
1
,
0
)))
goto
error
;
...
...
@@ -1435,10 +1433,8 @@ static ssize_t virNetSocketReadSASL(virNetSocketPtr sock, char *buf, size_t len)
if
(
sock
->
saslDecoded
==
NULL
)
{
ssize_t
encodedLen
=
virNetSASLSessionGetMaxBufSize
(
sock
->
saslSession
);
char
*
encoded
;
if
(
VIR_ALLOC_N
(
encoded
,
encodedLen
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
encoded
,
encodedLen
)
<
0
)
return
-
1
;
}
encodedLen
=
virNetSocketReadWire
(
sock
,
encoded
,
encodedLen
);
if
(
encodedLen
<=
0
)
{
...
...
src/rpc/virnetsshsession.c
浏览文件 @
ff50bdfd
...
...
@@ -378,7 +378,6 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
keyhash
,
sess
->
hostname
,
sess
->
port
,
"y"
,
"n"
)
<
0
)
{
virReportOOMError
();
VIR_FREE
(
keyhash
);
return
-
1
;
}
...
...
@@ -635,10 +634,8 @@ virNetSSHAuthenticatePrivkey(virNetSSHSessionPtr sess,
if
(
virAsprintf
((
char
**
)
&
retr_passphrase
.
prompt
,
_
(
"Passphrase for key '%s'"
),
priv
->
filename
)
<
0
)
{
virReportOOMError
();
priv
->
filename
)
<
0
)
return
-
1
;
}
if
(
sess
->
cred
->
cb
(
&
retr_passphrase
,
1
,
sess
->
cred
->
cbdata
))
{
virReportError
(
VIR_ERR_SSH
,
"%s"
,
...
...
@@ -966,10 +963,8 @@ virNetSSHSessionAuthAddPasswordAuth(virNetSSHSessionPtr sess,
VIR_STRDUP
(
pass
,
password
)
<
0
)
goto
error
;
if
(
!
(
auth
=
virNetSSHSessionAuthMethodNew
(
sess
)))
{
virReportOOMError
();
if
(
!
(
auth
=
virNetSSHSessionAuthMethodNew
(
sess
)))
goto
error
;
}
auth
->
username
=
user
;
auth
->
password
=
pass
;
...
...
@@ -1004,10 +999,8 @@ virNetSSHSessionAuthAddAgentAuth(virNetSSHSessionPtr sess,
if
(
VIR_STRDUP
(
user
,
username
)
<
0
)
goto
error
;
if
(
!
(
auth
=
virNetSSHSessionAuthMethodNew
(
sess
)))
{
virReportOOMError
();
if
(
!
(
auth
=
virNetSSHSessionAuthMethodNew
(
sess
)))
goto
error
;
}
auth
->
username
=
user
;
auth
->
method
=
VIR_NET_SSH_AUTH_AGENT
;
...
...
@@ -1047,10 +1040,8 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSessionPtr sess,
VIR_STRDUP
(
pass
,
password
)
<
0
)
goto
error
;
if
(
!
(
auth
=
virNetSSHSessionAuthMethodNew
(
sess
)))
{
virReportOOMError
();
if
(
!
(
auth
=
virNetSSHSessionAuthMethodNew
(
sess
)))
goto
error
;
}
auth
->
username
=
user
;
auth
->
password
=
pass
;
...
...
@@ -1088,10 +1079,8 @@ virNetSSHSessionAuthAddKeyboardAuth(virNetSSHSessionPtr sess,
if
(
VIR_STRDUP
(
user
,
username
)
<
0
)
goto
error
;
if
(
!
(
auth
=
virNetSSHSessionAuthMethodNew
(
sess
)))
{
virReportOOMError
();
if
(
!
(
auth
=
virNetSSHSessionAuthMethodNew
(
sess
)))
goto
error
;
}
auth
->
username
=
user
;
auth
->
tries
=
tries
;
...
...
src/rpc/virnettlscontext.c
浏览文件 @
ff50bdfd
...
...
@@ -314,10 +314,8 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
return
-
1
;
}
if
(
VIR_ALLOC_N
(
buffer
,
size
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
buffer
,
size
)
<
0
)
return
-
1
;
}
status
=
gnutls_x509_crt_get_key_purpose_oid
(
cert
,
i
,
buffer
,
&
size
,
&
purposeCritical
);
if
(
status
<
0
)
{
...
...
@@ -776,17 +774,17 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
VIR_DEBUG
(
"Told to use TLS credentials in %s"
,
pkipath
);
if
((
virAsprintf
(
cacert
,
"%s/%s"
,
pkipath
,
"cacert.pem"
))
<
0
)
goto
out_of_memory
;
goto
error
;
if
((
virAsprintf
(
cacrl
,
"%s/%s"
,
pkipath
,
"cacrl.pem"
))
<
0
)
goto
out_of_memory
;
goto
error
;
if
((
virAsprintf
(
key
,
"%s/%s"
,
pkipath
,
isServer
?
"serverkey.pem"
:
"clientkey.pem"
))
<
0
)
goto
out_of_memory
;
goto
error
;
if
((
virAsprintf
(
cert
,
"%s/%s"
,
pkipath
,
isServer
?
"servercert.pem"
:
"clientcert.pem"
))
<
0
)
goto
out_of_memory
;
goto
error
;
}
else
if
(
tryUserPkiPath
)
{
/* Check to see if $HOME/.pki contains at least one of the
* files and if so, use that
...
...
@@ -794,28 +792,28 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
userdir
=
virGetUserDirectory
();
if
(
!
userdir
)
goto
out_of_memory
;
goto
error
;
if
(
virAsprintf
(
&
user_pki_path
,
"%s/.pki/libvirt"
,
userdir
)
<
0
)
goto
out_of_memory
;
goto
error
;
VIR_DEBUG
(
"Trying to find TLS user credentials in %s"
,
user_pki_path
);
if
((
virAsprintf
(
cacert
,
"%s/%s"
,
user_pki_path
,
"cacert.pem"
))
<
0
)
goto
out_of_memory
;
goto
error
;
if
((
virAsprintf
(
cacrl
,
"%s/%s"
,
user_pki_path
,
"cacrl.pem"
))
<
0
)
goto
out_of_memory
;
goto
error
;
if
((
virAsprintf
(
key
,
"%s/%s"
,
user_pki_path
,
isServer
?
"serverkey.pem"
:
"clientkey.pem"
))
<
0
)
goto
out_of_memory
;
goto
error
;
if
((
virAsprintf
(
cert
,
"%s/%s"
,
user_pki_path
,
isServer
?
"servercert.pem"
:
"clientcert.pem"
))
<
0
)
goto
out_of_memory
;
goto
error
;
/*
* If some of the files can't be found, fallback
...
...
@@ -864,8 +862,6 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
return
0
;
out_of_memory:
virReportOOMError
();
error:
VIR_FREE
(
*
cacert
);
VIR_FREE
(
*
cacrl
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录