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
b3fc069e
Unverified
Commit
b3fc069e
authored
Dec 11, 2018
by
Wolfgang Bumiller
Committed by
GitHub
Dec 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2749 from brauner/2018-12-11/storage_utils
storage: src cannot be truncated
parents
be50a0d9
4f08c8d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
61 deletions
+0
-61
storage_utils.c
src/lxc/storage/storage_utils.c
+0
-59
storage_utils.h
src/lxc/storage/storage_utils.h
+0
-2
No files found.
src/lxc/storage/storage_utils.c
View file @
b3fc069e
...
@@ -61,65 +61,6 @@
...
@@ -61,65 +61,6 @@
lxc_log_define
(
storage_utils
,
lxc
);
lxc_log_define
(
storage_utils
,
lxc
);
/* the bulk of this needs to become a common helper */
char
*
dir_new_path
(
char
*
src
,
const
char
*
oldname
,
const
char
*
name
,
const
char
*
oldpath
,
const
char
*
lxcpath
)
{
char
*
ret
,
*
p
,
*
p2
;
int
l1
,
l2
,
nlen
;
nlen
=
strlen
(
src
)
+
1
;
l1
=
strlen
(
oldpath
);
p
=
src
;
/* if src starts with oldpath, look for oldname only after
* that path */
if
(
strncmp
(
src
,
oldpath
,
l1
)
==
0
)
{
p
+=
l1
;
nlen
+=
(
strlen
(
lxcpath
)
-
l1
);
}
l2
=
strlen
(
oldname
);
while
((
p
=
strstr
(
p
,
oldname
))
!=
NULL
)
{
p
+=
l2
;
nlen
+=
strlen
(
name
)
-
l2
;
}
ret
=
malloc
(
nlen
);
if
(
!
ret
)
return
NULL
;
p
=
ret
;
if
(
strncmp
(
src
,
oldpath
,
l1
)
==
0
)
{
p
+=
sprintf
(
p
,
"%s"
,
lxcpath
);
src
+=
l1
;
}
while
((
p2
=
strstr
(
src
,
oldname
))
!=
NULL
)
{
size_t
retlen
;
/* copy text up to oldname */
retlen
=
strlcpy
(
p
,
src
,
p2
-
src
);
if
(
retlen
>=
p2
-
src
)
{
free
(
ret
);
return
NULL
;
}
/* move target pointer (p) */
p
+=
p2
-
src
;
/* print new name in place of oldname */
p
+=
sprintf
(
p
,
"%s"
,
name
);
/* move src to end of oldname */
src
=
p2
+
l2
;
}
/* copy the rest of src */
sprintf
(
p
,
"%s"
,
src
);
return
ret
;
}
/*
/*
* attach_block_device returns true if all went well,
* attach_block_device returns true if all went well,
* meaning either a block device was attached or was not
* meaning either a block device was attached or was not
...
...
src/lxc/storage/storage_utils.h
View file @
b3fc069e
...
@@ -33,8 +33,6 @@
...
@@ -33,8 +33,6 @@
struct
lxc_storage
;
struct
lxc_storage
;
struct
lxc_conf
;
struct
lxc_conf
;
extern
char
*
dir_new_path
(
char
*
src
,
const
char
*
oldname
,
const
char
*
name
,
const
char
*
oldpath
,
const
char
*
lxcpath
);
extern
bool
attach_block_device
(
struct
lxc_conf
*
conf
);
extern
bool
attach_block_device
(
struct
lxc_conf
*
conf
);
extern
void
detach_block_device
(
struct
lxc_conf
*
conf
);
extern
void
detach_block_device
(
struct
lxc_conf
*
conf
);
extern
int
blk_getsize
(
struct
lxc_storage
*
bdev
,
uint64_t
*
size
);
extern
int
blk_getsize
(
struct
lxc_storage
*
bdev
,
uint64_t
*
size
);
...
...
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