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
b84663a8
Unverified
Commit
b84663a8
authored
May 30, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Jul 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add lxc_safe_ulong()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
61e3ec8f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
utils.c
src/lxc/utils.c
+23
-0
utils.h
src/lxc/utils.h
+1
-0
No files found.
src/lxc/utils.c
View file @
b84663a8
...
@@ -2021,6 +2021,29 @@ int lxc_safe_uint(const char *numstr, unsigned int *converted)
...
@@ -2021,6 +2021,29 @@ int lxc_safe_uint(const char *numstr, unsigned int *converted)
return
0
;
return
0
;
}
}
int
lxc_safe_ulong
(
const
char
*
numstr
,
unsigned
long
*
converted
)
{
char
*
err
=
NULL
;
unsigned
long
int
uli
;
while
(
isspace
(
*
numstr
))
numstr
++
;
if
(
*
numstr
==
'-'
)
return
-
EINVAL
;
errno
=
0
;
uli
=
strtoul
(
numstr
,
&
err
,
0
);
if
(
errno
==
ERANGE
&&
uli
==
ULONG_MAX
)
return
-
ERANGE
;
if
(
err
==
numstr
||
*
err
!=
'\0'
)
return
-
EINVAL
;
*
converted
=
uli
;
return
0
;
}
int
lxc_safe_int
(
const
char
*
numstr
,
int
*
converted
)
int
lxc_safe_int
(
const
char
*
numstr
,
int
*
converted
)
{
{
char
*
err
=
NULL
;
char
*
err
=
NULL
;
...
...
src/lxc/utils.h
View file @
b84663a8
...
@@ -340,6 +340,7 @@ bool task_blocking_signal(pid_t pid, int signal);
...
@@ -340,6 +340,7 @@ bool task_blocking_signal(pid_t pid, int signal);
int
lxc_safe_uint
(
const
char
*
numstr
,
unsigned
int
*
converted
);
int
lxc_safe_uint
(
const
char
*
numstr
,
unsigned
int
*
converted
);
int
lxc_safe_int
(
const
char
*
numstr
,
int
*
converted
);
int
lxc_safe_int
(
const
char
*
numstr
,
int
*
converted
);
int
lxc_safe_long
(
const
char
*
numstr
,
long
int
*
converted
);
int
lxc_safe_long
(
const
char
*
numstr
,
long
int
*
converted
);
int
lxc_safe_ulong
(
const
char
*
numstr
,
unsigned
long
*
converted
);
/* Switch to a new uid and gid. */
/* Switch to a new uid and gid. */
int
lxc_switch_uid_gid
(
uid_t
uid
,
gid_t
gid
);
int
lxc_switch_uid_gid
(
uid_t
uid
,
gid_t
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