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
bd583214
Unverified
Commit
bd583214
authored
Jun 21, 2018
by
Donghwa Jeong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: strncat => strlcat
Signed-off-by:
Donghwa Jeong
<
dh48.jeong@samsung.com
>
parent
e0576f17
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
13 deletions
+29
-13
utils.c
src/lxc/pam/utils.c
+9
-3
utils.c
src/lxc/utils.c
+20
-10
No files found.
src/lxc/pam/utils.c
View file @
bd583214
...
...
@@ -33,6 +33,10 @@
#include "utils.h"
#ifndef HAVE_STRLCAT
#include "include/strlcat.h"
#endif
bool
file_exists
(
const
char
*
f
)
{
struct
stat
statbuf
;
...
...
@@ -69,6 +73,7 @@ char *must_make_path(const char *first, ...)
va_list
args
;
char
*
cur
,
*
dest
;
size_t
full_len
=
strlen
(
first
);
size_t
buf_len
;
dest
=
must_copy_string
(
first
);
...
...
@@ -78,11 +83,12 @@ char *must_make_path(const char *first, ...)
if
(
cur
[
0
]
!=
'/'
)
full_len
++
;
dest
=
must_realloc
(
dest
,
full_len
+
1
);
buf_len
=
full_len
+
1
;
dest
=
must_realloc
(
dest
,
buf_len
);
if
(
cur
[
0
]
!=
'/'
)
strncat
(
dest
,
"/"
,
1
);
strncat
(
dest
,
cur
,
strlen
(
cur
)
);
(
void
)
strlcat
(
dest
,
"/"
,
buf_len
);
(
void
)
strlcat
(
dest
,
cur
,
buf_len
);
}
va_end
(
args
);
...
...
src/lxc/utils.c
View file @
bd583214
...
...
@@ -55,6 +55,10 @@
#include "include/strlcpy.h"
#endif
#ifndef HAVE_STRLCAT
#include "include/strlcat.h"
#endif
#ifndef O_PATH
#define O_PATH 010000000
#endif
...
...
@@ -635,22 +639,24 @@ char *lxc_string_join(const char *sep, const char **parts, bool use_as_prefix)
char
**
p
;
size_t
sep_len
=
strlen
(
sep
);
size_t
result_len
=
use_as_prefix
*
sep_len
;
size_t
buf_len
;
/* calculate new string length */
for
(
p
=
(
char
**
)
parts
;
*
p
;
p
++
)
result_len
+=
(
p
>
(
char
**
)
parts
)
*
sep_len
+
strlen
(
*
p
);
result
=
calloc
(
result_len
+
1
,
1
);
buf_len
=
result_len
+
1
;
result
=
calloc
(
buf_len
,
1
);
if
(
!
result
)
return
NULL
;
if
(
use_as_prefix
)
(
void
)
strlcpy
(
result
,
sep
,
result_len
+
1
);
(
void
)
strlcpy
(
result
,
sep
,
buf_len
);
for
(
p
=
(
char
**
)
parts
;
*
p
;
p
++
)
{
if
(
p
>
(
char
**
)
parts
)
strncat
(
result
,
sep
,
sep
_len
);
strncat
(
result
,
*
p
,
strlen
(
*
p
)
);
(
void
)
strlcat
(
result
,
sep
,
buf
_len
);
(
void
)
strlcat
(
result
,
*
p
,
buf_len
);
}
return
result
;
...
...
@@ -2310,6 +2316,7 @@ char *must_make_path(const char *first, ...)
va_list
args
;
char
*
cur
,
*
dest
;
size_t
full_len
=
strlen
(
first
);
size_t
buf_len
;
dest
=
must_copy_string
(
first
);
...
...
@@ -2319,11 +2326,12 @@ char *must_make_path(const char *first, ...)
if
(
cur
[
0
]
!=
'/'
)
full_len
++
;
dest
=
must_realloc
(
dest
,
full_len
+
1
);
buf_len
=
full_len
+
1
;
dest
=
must_realloc
(
dest
,
buf_len
);
if
(
cur
[
0
]
!=
'/'
)
strncat
(
dest
,
"/"
,
1
);
strncat
(
dest
,
cur
,
strlen
(
cur
)
);
(
void
)
strlcat
(
dest
,
"/"
,
buf_len
);
(
void
)
strlcat
(
dest
,
cur
,
buf_len
);
}
va_end
(
args
);
...
...
@@ -2336,6 +2344,7 @@ char *must_append_path(char *first, ...)
size_t
full_len
;
va_list
args
;
char
*
dest
=
first
;
size_t
buf_len
;
full_len
=
strlen
(
first
);
va_start
(
args
,
first
);
...
...
@@ -2344,11 +2353,12 @@ char *must_append_path(char *first, ...)
if
(
cur
[
0
]
!=
'/'
)
full_len
++
;
dest
=
must_realloc
(
dest
,
full_len
+
1
);
buf_len
=
full_len
+
1
;
dest
=
must_realloc
(
dest
,
buf_len
);
if
(
cur
[
0
]
!=
'/'
)
strncat
(
dest
,
"/"
,
1
);
strncat
(
dest
,
cur
,
strlen
(
cur
)
);
(
void
)
strlcat
(
dest
,
"/"
,
buf_len
);
(
void
)
strlcat
(
dest
,
cur
,
buf_len
);
}
va_end
(
args
);
...
...
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