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
b037bc67
Unverified
Commit
b037bc67
authored
Oct 18, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add lxc_safe_long_long()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
f3d05ee6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
utils.c
src/lxc/utils.c
+20
-0
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
b037bc67
...
...
@@ -2003,6 +2003,26 @@ int lxc_safe_long(const char *numstr, long int *converted)
return
0
;
}
int
lxc_safe_long_long
(
const
char
*
numstr
,
long
long
int
*
converted
)
{
char
*
err
=
NULL
;
signed
long
long
int
sli
;
errno
=
0
;
sli
=
strtoll
(
numstr
,
&
err
,
0
);
if
(
errno
==
ERANGE
&&
(
sli
==
LLONG_MAX
||
sli
==
LLONG_MIN
))
return
-
ERANGE
;
if
(
errno
!=
0
&&
sli
==
0
)
return
-
EINVAL
;
if
(
err
==
numstr
||
*
err
!=
'\0'
)
return
-
EINVAL
;
*
converted
=
sli
;
return
0
;
}
int
lxc_switch_uid_gid
(
uid_t
uid
,
gid_t
gid
)
{
if
(
setgid
(
gid
)
<
0
)
{
...
...
src/lxc/utils.h
View file @
b037bc67
...
...
@@ -419,6 +419,7 @@ extern bool task_blocking_signal(pid_t pid, int signal);
extern
int
lxc_safe_uint
(
const
char
*
numstr
,
unsigned
int
*
converted
);
extern
int
lxc_safe_int
(
const
char
*
numstr
,
int
*
converted
);
extern
int
lxc_safe_long
(
const
char
*
numstr
,
long
int
*
converted
);
extern
int
lxc_safe_long_long
(
const
char
*
numstr
,
long
long
int
*
converted
);
extern
int
lxc_safe_ulong
(
const
char
*
numstr
,
unsigned
long
*
converted
);
/* Switch to a new uid and gid. */
...
...
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