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
2cb80427
Commit
2cb80427
authored
Sep 08, 2016
by
Tycho Andersen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c/r: zero a smaller than known migrate_opts struct
Signed-off-by:
Tycho Andersen
<
tycho.andersen@canonical.com
>
parent
d32bcb17
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
lxccontainer.c
src/lxc/lxccontainer.c
+17
-3
No files found.
src/lxc/lxccontainer.c
View file @
2cb80427
...
@@ -3960,6 +3960,7 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
...
@@ -3960,6 +3960,7 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
struct
migrate_opts
*
opts
,
unsigned
int
size
)
struct
migrate_opts
*
opts
,
unsigned
int
size
)
{
{
int
ret
;
int
ret
;
struct
migrate_opts
*
valid_opts
=
opts
;
/* If the caller has a bigger (newer) struct migrate_opts, let's make
/* If the caller has a bigger (newer) struct migrate_opts, let's make
* sure that the stuff on the end is zero, i.e. that they didn't ask us
* sure that the stuff on the end is zero, i.e. that they didn't ask us
...
@@ -3978,15 +3979,28 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
...
@@ -3978,15 +3979,28 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
}
}
}
}
/* If the caller has a smaller struct, let's zero out the end for them
* so we don't accidentally use bits of it that they didn't know about
* to initialize.
*/
if
(
size
<
sizeof
(
*
opts
))
{
valid_opts
=
malloc
(
sizeof
(
*
opts
));
if
(
!
valid_opts
)
return
-
ENOMEM
;
memset
(
valid_opts
,
0
,
sizeof
(
*
opts
));
memcpy
(
valid_opts
,
opts
,
size
);
}
switch
(
cmd
)
{
switch
(
cmd
)
{
case
MIGRATE_PRE_DUMP
:
case
MIGRATE_PRE_DUMP
:
ret
=
!
__criu_pre_dump
(
c
,
opts
);
ret
=
!
__criu_pre_dump
(
c
,
valid_
opts
);
break
;
break
;
case
MIGRATE_DUMP
:
case
MIGRATE_DUMP
:
ret
=
!
__criu_dump
(
c
,
opts
);
ret
=
!
__criu_dump
(
c
,
valid_
opts
);
break
;
break
;
case
MIGRATE_RESTORE
:
case
MIGRATE_RESTORE
:
ret
=
!
__criu_restore
(
c
,
opts
);
ret
=
!
__criu_restore
(
c
,
valid_
opts
);
break
;
break
;
default
:
default
:
ERROR
(
"invalid migrate command %u"
,
cmd
);
ERROR
(
"invalid migrate command %u"
,
cmd
);
...
...
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