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
3874902c
Unverified
Commit
3874902c
authored
Sep 09, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Sep 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/overlay: do not write to invalid memory
Closes #1802. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
c0b3869f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
overlay.c
src/lxc/storage/overlay.c
+20
-19
No files found.
src/lxc/storage/overlay.c
View file @
3874902c
...
@@ -109,9 +109,9 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
...
@@ -109,9 +109,9 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
return
-
1
;
return
-
1
;
}
}
strn
cpy
(
delta
,
new
->
dest
,
lastslashidx
+
1
);
mem
cpy
(
delta
,
new
->
dest
,
lastslashidx
+
1
);
strn
cpy
(
delta
+
lastslashidx
,
"delta0"
,
sizeof
(
"delta0"
)
-
1
);
mem
cpy
(
delta
+
lastslashidx
,
"delta0"
,
sizeof
(
"delta0"
)
-
1
);
delta
[
lastslashidx
+
sizeof
(
"delta0"
)]
=
'\0'
;
delta
[
lastslashidx
+
sizeof
(
"delta0"
)
-
1
]
=
'\0'
;
ret
=
mkdir
(
delta
,
0755
);
ret
=
mkdir
(
delta
,
0755
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
...
@@ -141,12 +141,13 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
...
@@ -141,12 +141,13 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
return
-
1
;
return
-
1
;
}
}
strn
cpy
(
work
,
new
->
dest
,
lastslashidx
+
1
);
mem
cpy
(
work
,
new
->
dest
,
lastslashidx
+
1
);
strn
cpy
(
work
+
lastslashidx
,
"olwork"
,
sizeof
(
"olwork"
)
-
1
);
mem
cpy
(
work
+
lastslashidx
,
"olwork"
,
sizeof
(
"olwork"
)
-
1
);
work
[
lastslashidx
+
sizeof
(
"olwork"
)]
=
'\0'
;
work
[
lastslashidx
+
sizeof
(
"olwork"
)
-
1
]
=
'\0'
;
if
(
mkdir
(
work
,
0755
)
<
0
)
{
ret
=
mkdir
(
work
,
0755
);
SYSERROR
(
"error: mkdir %s"
,
work
);
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
work
);
free
(
delta
);
free
(
delta
);
free
(
work
);
free
(
work
);
return
-
1
;
return
-
1
;
...
@@ -253,9 +254,9 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
...
@@ -253,9 +254,9 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
return
-
1
;
return
-
1
;
}
}
strn
cpy
(
work
,
ndelta
,
lastslashidx
+
1
);
mem
cpy
(
work
,
ndelta
,
lastslashidx
+
1
);
strn
cpy
(
work
+
lastslashidx
,
"olwork"
,
sizeof
(
"olwork"
)
-
1
);
mem
cpy
(
work
+
lastslashidx
,
"olwork"
,
sizeof
(
"olwork"
)
-
1
);
work
[
lastslashidx
+
sizeof
(
"olwork"
)]
=
'\0'
;
work
[
lastslashidx
+
sizeof
(
"olwork"
)
-
1
]
=
'\0'
;
ret
=
mkdir
(
work
,
0755
);
ret
=
mkdir
(
work
,
0755
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
...
@@ -417,8 +418,8 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n,
...
@@ -417,8 +418,8 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n,
return
-
1
;
return
-
1
;
}
}
strn
cpy
(
delta
,
dest
,
len
);
mem
cpy
(
delta
,
dest
,
len
);
strn
cpy
(
delta
+
len
-
6
,
"delta0"
,
sizeof
(
"delta0"
)
-
1
);
mem
cpy
(
delta
+
len
-
6
,
"delta0"
,
sizeof
(
"delta0"
)
-
1
);
delta
[
len
+
sizeof
(
"delta0"
)]
=
'\0'
;
delta
[
len
+
sizeof
(
"delta0"
)]
=
'\0'
;
ret
=
mkdir_p
(
delta
,
0755
);
ret
=
mkdir_p
(
delta
,
0755
);
...
@@ -575,9 +576,9 @@ int ovl_mount(struct lxc_storage *bdev)
...
@@ -575,9 +576,9 @@ int ovl_mount(struct lxc_storage *bdev)
return
-
22
;
return
-
22
;
}
}
strn
cpy
(
work
,
upper
,
lastslashidx
+
1
);
mem
cpy
(
work
,
upper
,
lastslashidx
+
1
);
strn
cpy
(
work
+
lastslashidx
,
"olwork"
,
sizeof
(
"olwork"
)
-
1
);
mem
cpy
(
work
+
lastslashidx
,
"olwork"
,
sizeof
(
"olwork"
)
-
1
);
work
[
lastslashidx
+
sizeof
(
"olwork"
)]
=
'\0'
;
work
[
lastslashidx
+
sizeof
(
"olwork"
)
-
1
]
=
'\0'
;
ret
=
parse_mntopts
(
bdev
->
mntopts
,
&
mntflags
,
&
mntdata
);
ret
=
parse_mntopts
(
bdev
->
mntopts
,
&
mntflags
,
&
mntdata
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -747,8 +748,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -747,8 +748,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
char
lxcpath
[
MAXPATHLEN
];
char
lxcpath
[
MAXPATHLEN
];
char
**
opts
;
char
**
opts
;
int
ret
;
int
ret
;
size_t
arrlen
,
dirlen
,
i
,
len
,
rootfslen
;
size_t
arrlen
,
i
,
len
,
rootfslen
;
int
fret
=
-
1
;
int
fret
=
-
1
;
size_t
dirlen
=
0
;
char
*
rootfs_dir
=
NULL
,
*
rootfs_path
=
NULL
,
*
upperdir
=
NULL
,
char
*
rootfs_dir
=
NULL
,
*
rootfs_path
=
NULL
,
*
upperdir
=
NULL
,
*
workdir
=
NULL
;
*
workdir
=
NULL
;
...
@@ -772,8 +774,7 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
...
@@ -772,8 +774,7 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
}
}
if
(
rootfs_path
)
{
if
(
rootfs_path
)
{
ret
=
ret
=
snprintf
(
lxcpath
,
MAXPATHLEN
,
"%s/%s"
,
lxc_path
,
lxc_name
);
snprintf
(
lxcpath
,
MAXPATHLEN
,
"%s/%s"
,
lxc_path
,
lxc_name
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
goto
err
;
goto
err
;
...
...
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