Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
5265a60c
Unverified
Commit
5265a60c
authored
Feb 05, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: remove stack allocations
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
fa4719e2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
21 deletions
+5
-21
commands.c
src/lxc/commands.c
+5
-21
No files found.
src/lxc/commands.c
View file @
5265a60c
...
@@ -48,6 +48,7 @@
...
@@ -48,6 +48,7 @@
#include "lxc.h"
#include "lxc.h"
#include "lxclock.h"
#include "lxclock.h"
#include "mainloop.h"
#include "mainloop.h"
#include "memory_utils.h"
#include "monitor.h"
#include "monitor.h"
#include "start.h"
#include "start.h"
#include "terminal.h"
#include "terminal.h"
...
@@ -524,8 +525,8 @@ char *lxc_cmd_get_config_item(const char *name, const char *item,
...
@@ -524,8 +525,8 @@ char *lxc_cmd_get_config_item(const char *name, const char *item,
static
int
lxc_cmd_get_config_item_callback
(
int
fd
,
struct
lxc_cmd_req
*
req
,
static
int
lxc_cmd_get_config_item_callback
(
int
fd
,
struct
lxc_cmd_req
*
req
,
struct
lxc_handler
*
handler
)
struct
lxc_handler
*
handler
)
{
{
__do_free
char
*
cidata
=
NULL
;
int
cilen
;
int
cilen
;
char
*
cidata
;
struct
lxc_config_t
*
item
;
struct
lxc_config_t
*
item
;
struct
lxc_cmd_rsp
rsp
;
struct
lxc_cmd_rsp
rsp
;
...
@@ -538,7 +539,7 @@ static int lxc_cmd_get_config_item_callback(int fd, struct lxc_cmd_req *req,
...
@@ -538,7 +539,7 @@ static int lxc_cmd_get_config_item_callback(int fd, struct lxc_cmd_req *req,
if
(
cilen
<=
0
)
if
(
cilen
<=
0
)
goto
err1
;
goto
err1
;
cidata
=
alloca
(
cilen
+
1
);
cidata
=
must_realloc
(
NULL
,
cilen
+
1
);
if
(
item
->
get
(
req
->
data
,
cidata
,
cilen
+
1
,
handler
->
conf
,
NULL
)
!=
cilen
)
if
(
item
->
get
(
req
->
data
,
cidata
,
cilen
+
1
,
handler
->
conf
,
NULL
)
!=
cilen
)
goto
err1
;
goto
err1
;
...
@@ -1103,9 +1104,9 @@ static void lxc_cmd_fd_cleanup(int fd, struct lxc_handler *handler,
...
@@ -1103,9 +1104,9 @@ static void lxc_cmd_fd_cleanup(int fd, struct lxc_handler *handler,
static
int
lxc_cmd_handler
(
int
fd
,
uint32_t
events
,
void
*
data
,
static
int
lxc_cmd_handler
(
int
fd
,
uint32_t
events
,
void
*
data
,
struct
lxc_epoll_descr
*
descr
)
struct
lxc_epoll_descr
*
descr
)
{
{
__do_free
void
*
reqdata
=
NULL
;
int
ret
;
int
ret
;
struct
lxc_cmd_req
req
;
struct
lxc_cmd_req
req
;
void
*
reqdata
=
NULL
;
struct
lxc_handler
*
handler
=
data
;
struct
lxc_handler
*
handler
=
data
;
ret
=
lxc_abstract_unix_rcv_credential
(
fd
,
&
req
,
sizeof
(
req
));
ret
=
lxc_abstract_unix_rcv_credential
(
fd
,
&
req
,
sizeof
(
req
));
...
@@ -1143,21 +1144,7 @@ static int lxc_cmd_handler(int fd, uint32_t events, void *data,
...
@@ -1143,21 +1144,7 @@ static int lxc_cmd_handler(int fd, uint32_t events, void *data,
}
}
if
(
req
.
datalen
>
0
)
{
if
(
req
.
datalen
>
0
)
{
/* LXC_CMD_CONSOLE_LOG needs to be able to allocate data
reqdata
=
must_realloc
(
NULL
,
req
.
datalen
);
* that exceeds LXC_CMD_DATA_MAX: use malloc() for that.
*/
if
(
req
.
cmd
==
LXC_CMD_CONSOLE_LOG
)
reqdata
=
malloc
(
req
.
datalen
);
else
reqdata
=
alloca
(
req
.
datalen
);
if
(
!
reqdata
)
{
ERROR
(
"Failed to allocate memory for
\"
%s
\"
command"
,
lxc_cmd_str
(
req
.
cmd
));
errno
=
ENOMEM
;
ret
=
-
ENOMEM
;
goto
out_close
;
}
ret
=
lxc_recv_nointr
(
fd
,
reqdata
,
req
.
datalen
,
0
);
ret
=
lxc_recv_nointr
(
fd
,
reqdata
,
req
.
datalen
,
0
);
if
(
ret
!=
req
.
datalen
)
{
if
(
ret
!=
req
.
datalen
)
{
WARN
(
"Failed to receive full command request. Ignoring "
WARN
(
"Failed to receive full command request. Ignoring "
...
@@ -1177,9 +1164,6 @@ static int lxc_cmd_handler(int fd, uint32_t events, void *data,
...
@@ -1177,9 +1164,6 @@ static int lxc_cmd_handler(int fd, uint32_t events, void *data,
}
}
out:
out:
if
(
req
.
cmd
==
LXC_CMD_CONSOLE_LOG
&&
reqdata
)
free
(
reqdata
);
return
ret
;
return
ret
;
out_close:
out_close:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment