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
18105e58
Unverified
Commit
18105e58
authored
Feb 11, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: convert to strnprintf()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
b4d3e2f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
confile.c
src/lxc/confile.c
+17
-19
No files found.
src/lxc/confile.c
View file @
18105e58
...
@@ -2386,8 +2386,8 @@ static int do_includedir(const char *dirp, struct lxc_conf *lxc_conf)
...
@@ -2386,8 +2386,8 @@ static int do_includedir(const char *dirp, struct lxc_conf *lxc_conf)
if
(
len
<
6
||
strncmp
(
fnam
+
len
-
5
,
".conf"
,
5
)
!=
0
)
if
(
len
<
6
||
strncmp
(
fnam
+
len
-
5
,
".conf"
,
5
)
!=
0
)
continue
;
continue
;
len
=
s
nprintf
(
path
,
PATH_MAX
,
"%s/%s"
,
dirp
,
fnam
);
len
=
s
trnprintf
(
path
,
sizeof
(
path
)
,
"%s/%s"
,
dirp
,
fnam
);
if
(
len
<
0
||
len
>=
PATH_MAX
)
if
(
len
<
0
)
return
ret_errno
(
EIO
);
return
ret_errno
(
EIO
);
ret
=
lxc_config_read
(
path
,
lxc_conf
,
true
);
ret
=
lxc_config_read
(
path
,
lxc_conf
,
true
);
...
@@ -2895,10 +2895,10 @@ bool do_append_unexp_config_line(struct lxc_conf *conf, const char *key,
...
@@ -2895,10 +2895,10 @@ bool do_append_unexp_config_line(struct lxc_conf *conf, const char *key,
tmp
=
must_realloc
(
NULL
,
len
);
tmp
=
must_realloc
(
NULL
,
len
);
if
(
lxc_config_value_empty
(
v
))
if
(
lxc_config_value_empty
(
v
))
ret
=
snprintf
(
tmp
,
len
,
"%s ="
,
key
);
ret
=
s
tr
nprintf
(
tmp
,
len
,
"%s ="
,
key
);
else
else
ret
=
snprintf
(
tmp
,
len
,
"%s = %s"
,
key
,
v
);
ret
=
s
tr
nprintf
(
tmp
,
len
,
"%s = %s"
,
key
,
v
);
if
(
ret
<
0
||
ret
>=
len
)
if
(
ret
<
0
)
return
false
;
return
false
;
/* Save the line verbatim into unexpanded_conf */
/* Save the line verbatim into unexpanded_conf */
...
@@ -2963,16 +2963,14 @@ bool clone_update_unexp_ovl_paths(struct lxc_conf *conf, const char *oldpath,
...
@@ -2963,16 +2963,14 @@ bool clone_update_unexp_ovl_paths(struct lxc_conf *conf, const char *oldpath,
olddirlen
=
strlen
(
ovldir
)
+
strlen
(
oldpath
)
+
strlen
(
oldname
)
+
2
;
olddirlen
=
strlen
(
ovldir
)
+
strlen
(
oldpath
)
+
strlen
(
oldname
)
+
2
;
olddir
=
must_realloc
(
NULL
,
olddirlen
+
1
);
olddir
=
must_realloc
(
NULL
,
olddirlen
+
1
);
ret
=
snprintf
(
olddir
,
olddirlen
+
1
,
"%s=%s/%s"
,
ovldir
,
oldpath
,
ret
=
strnprintf
(
olddir
,
olddirlen
+
1
,
"%s=%s/%s"
,
ovldir
,
oldpath
,
oldname
);
oldname
);
if
(
ret
<
0
)
if
(
ret
<
0
||
ret
>=
olddirlen
+
1
)
return
false
;
return
false
;
newdirlen
=
strlen
(
ovldir
)
+
strlen
(
newpath
)
+
strlen
(
newname
)
+
2
;
newdirlen
=
strlen
(
ovldir
)
+
strlen
(
newpath
)
+
strlen
(
newname
)
+
2
;
newdir
=
must_realloc
(
NULL
,
newdirlen
+
1
);
newdir
=
must_realloc
(
NULL
,
newdirlen
+
1
);
ret
=
snprintf
(
newdir
,
newdirlen
+
1
,
"%s=%s/%s"
,
ovldir
,
newpath
,
ret
=
strnprintf
(
newdir
,
newdirlen
+
1
,
"%s=%s/%s"
,
ovldir
,
newpath
,
newname
);
newname
);
if
(
ret
<
0
)
if
(
ret
<
0
||
ret
>=
newdirlen
+
1
)
return
false
;
return
false
;
if
(
!
conf
->
unexpanded_config
)
if
(
!
conf
->
unexpanded_config
)
...
@@ -3072,14 +3070,14 @@ bool clone_update_unexp_hooks(struct lxc_conf *conf, const char *oldpath,
...
@@ -3072,14 +3070,14 @@ bool clone_update_unexp_hooks(struct lxc_conf *conf, const char *oldpath,
olddirlen
=
strlen
(
oldpath
)
+
strlen
(
oldname
)
+
1
;
olddirlen
=
strlen
(
oldpath
)
+
strlen
(
oldname
)
+
1
;
olddir
=
must_realloc
(
NULL
,
olddirlen
+
1
);
olddir
=
must_realloc
(
NULL
,
olddirlen
+
1
);
ret
=
snprintf
(
olddir
,
olddirlen
+
1
,
"%s/%s"
,
oldpath
,
oldname
);
ret
=
s
tr
nprintf
(
olddir
,
olddirlen
+
1
,
"%s/%s"
,
oldpath
,
oldname
);
if
(
ret
<
0
||
ret
>=
olddirlen
+
1
)
if
(
ret
<
0
)
return
false
;
return
false
;
newdirlen
=
strlen
(
newpath
)
+
strlen
(
newname
)
+
1
;
newdirlen
=
strlen
(
newpath
)
+
strlen
(
newname
)
+
1
;
newdir
=
must_realloc
(
NULL
,
newdirlen
+
1
);
newdir
=
must_realloc
(
NULL
,
newdirlen
+
1
);
ret
=
snprintf
(
newdir
,
newdirlen
+
1
,
"%s/%s"
,
newpath
,
newname
);
ret
=
s
tr
nprintf
(
newdir
,
newdirlen
+
1
,
"%s/%s"
,
newpath
,
newname
);
if
(
ret
<
0
||
ret
>=
newdirlen
+
1
)
if
(
ret
<
0
)
return
false
;
return
false
;
if
(
!
conf
->
unexpanded_config
)
if
(
!
conf
->
unexpanded_config
)
...
@@ -3543,10 +3541,10 @@ static int get_config_idmaps(const char *key, char *retv, int inlen,
...
@@ -3543,10 +3541,10 @@ static int get_config_idmaps(const char *key, char *retv, int inlen,
listlen
=
lxc_list_len
(
&
c
->
id_map
);
listlen
=
lxc_list_len
(
&
c
->
id_map
);
lxc_list_for_each
(
it
,
&
c
->
id_map
)
{
lxc_list_for_each
(
it
,
&
c
->
id_map
)
{
struct
id_map
*
map
=
it
->
elem
;
struct
id_map
*
map
=
it
->
elem
;
ret
=
s
nprintf
(
buf
,
__LXC_IDMAP_STR_BUF
,
"%c %lu %lu %lu"
,
ret
=
s
trnprintf
(
buf
,
sizeof
(
buf
)
,
"%c %lu %lu %lu"
,
(
map
->
idtype
==
ID_TYPE_UID
)
?
'u'
:
'g'
,
(
map
->
idtype
==
ID_TYPE_UID
)
?
'u'
:
'g'
,
map
->
nsid
,
map
->
hostid
,
map
->
range
);
map
->
nsid
,
map
->
hostid
,
map
->
range
);
if
(
ret
<
0
||
ret
>=
__LXC_IDMAP_STR_BUF
)
if
(
ret
<
0
)
return
ret_errno
(
EIO
);
return
ret_errno
(
EIO
);
strprint
(
retv
,
inlen
,
"%s%s"
,
buf
,
(
listlen
--
>
1
)
?
"
\n
"
:
""
);
strprint
(
retv
,
inlen
,
"%s%s"
,
buf
,
(
listlen
--
>
1
)
?
"
\n
"
:
""
);
...
...
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