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
ce42ba2c
Commit
ce42ba2c
authored
Dec 12, 2013
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coverity: change flow to safely free in all exit paths
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
parent
88dd66fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
lxc_usernsexec.c
src/lxc/lxc_usernsexec.c
+19
-16
No files found.
src/lxc/lxc_usernsexec.c
View file @
ce42ba2c
...
@@ -258,13 +258,17 @@ static int map_child_uids(int pid, struct id_map *map)
...
@@ -258,13 +258,17 @@ static int map_child_uids(int pid, struct id_map *map)
{
{
char
**
uidargs
=
NULL
,
**
gidargs
=
NULL
;
char
**
uidargs
=
NULL
,
**
gidargs
=
NULL
;
char
**
newuidargs
=
NULL
,
**
newgidargs
=
NULL
;
char
**
newuidargs
=
NULL
,
**
newgidargs
=
NULL
;
int
i
,
nuargs
=
2
,
ngargs
=
2
;
int
i
,
nuargs
=
2
,
ngargs
=
2
,
ret
=
-
1
;
struct
id_map
*
m
;
struct
id_map
*
m
;
uidargs
=
malloc
(
3
*
sizeof
(
*
uidargs
));
uidargs
=
malloc
(
3
*
sizeof
(
*
uidargs
));
if
(
uidargs
==
NULL
)
return
-
1
;
gidargs
=
malloc
(
3
*
sizeof
(
*
gidargs
));
gidargs
=
malloc
(
3
*
sizeof
(
*
gidargs
));
if
(
uidargs
==
NULL
||
gidargs
==
NULL
)
if
(
gidargs
==
NULL
)
{
free
(
uidargs
);
return
-
1
;
return
-
1
;
}
uidargs
[
0
]
=
malloc
(
10
);
uidargs
[
0
]
=
malloc
(
10
);
gidargs
[
0
]
=
malloc
(
10
);
gidargs
[
0
]
=
malloc
(
10
);
uidargs
[
1
]
=
malloc
(
21
);
uidargs
[
1
]
=
malloc
(
21
);
...
@@ -272,7 +276,7 @@ static int map_child_uids(int pid, struct id_map *map)
...
@@ -272,7 +276,7 @@ static int map_child_uids(int pid, struct id_map *map)
uidargs
[
2
]
=
NULL
;
uidargs
[
2
]
=
NULL
;
gidargs
[
2
]
=
NULL
;
gidargs
[
2
]
=
NULL
;
if
(
!
uidargs
[
0
]
||
!
uidargs
[
1
]
||
!
gidargs
[
0
]
||
!
gidargs
[
1
])
if
(
!
uidargs
[
0
]
||
!
uidargs
[
1
]
||
!
gidargs
[
0
]
||
!
gidargs
[
1
])
return
-
1
;
goto
out
;
sprintf
(
uidargs
[
0
],
"newuidmap"
);
sprintf
(
uidargs
[
0
],
"newuidmap"
);
sprintf
(
gidargs
[
0
],
"newgidmap"
);
sprintf
(
gidargs
[
0
],
"newgidmap"
);
sprintf
(
uidargs
[
1
],
"%d"
,
pid
);
sprintf
(
uidargs
[
1
],
"%d"
,
pid
);
...
@@ -281,16 +285,14 @@ static int map_child_uids(int pid, struct id_map *map)
...
@@ -281,16 +285,14 @@ static int map_child_uids(int pid, struct id_map *map)
if
(
m
->
which
==
'b'
||
m
->
which
==
'u'
)
{
if
(
m
->
which
==
'b'
||
m
->
which
==
'u'
)
{
nuargs
+=
3
;
nuargs
+=
3
;
newuidargs
=
realloc
(
uidargs
,
(
nuargs
+
1
)
*
sizeof
(
*
uidargs
));
newuidargs
=
realloc
(
uidargs
,
(
nuargs
+
1
)
*
sizeof
(
*
uidargs
));
if
(
!
newuidargs
)
{
if
(
!
newuidargs
)
free
(
uidargs
);
goto
out
;
return
-
1
;
}
uidargs
=
newuidargs
;
uidargs
=
newuidargs
;
uidargs
[
nuargs
-
3
]
=
malloc
(
21
);
uidargs
[
nuargs
-
3
]
=
malloc
(
21
);
uidargs
[
nuargs
-
2
]
=
malloc
(
21
);
uidargs
[
nuargs
-
2
]
=
malloc
(
21
);
uidargs
[
nuargs
-
1
]
=
malloc
(
21
);
uidargs
[
nuargs
-
1
]
=
malloc
(
21
);
if
(
!
uidargs
[
nuargs
-
3
]
||
!
uidargs
[
nuargs
-
2
]
||
!
uidargs
[
nuargs
-
1
])
if
(
!
uidargs
[
nuargs
-
3
]
||
!
uidargs
[
nuargs
-
2
]
||
!
uidargs
[
nuargs
-
1
])
return
-
1
;
goto
out
;
sprintf
(
uidargs
[
nuargs
-
3
],
"%ld"
,
m
->
ns_id
);
sprintf
(
uidargs
[
nuargs
-
3
],
"%ld"
,
m
->
ns_id
);
sprintf
(
uidargs
[
nuargs
-
2
],
"%ld"
,
m
->
host_id
);
sprintf
(
uidargs
[
nuargs
-
2
],
"%ld"
,
m
->
host_id
);
sprintf
(
uidargs
[
nuargs
-
1
],
"%ld"
,
m
->
range
);
sprintf
(
uidargs
[
nuargs
-
1
],
"%ld"
,
m
->
range
);
...
@@ -299,16 +301,14 @@ static int map_child_uids(int pid, struct id_map *map)
...
@@ -299,16 +301,14 @@ static int map_child_uids(int pid, struct id_map *map)
if
(
m
->
which
==
'b'
||
m
->
which
==
'g'
)
{
if
(
m
->
which
==
'b'
||
m
->
which
==
'g'
)
{
ngargs
+=
3
;
ngargs
+=
3
;
newgidargs
=
realloc
(
gidargs
,
(
ngargs
+
1
)
*
sizeof
(
*
gidargs
));
newgidargs
=
realloc
(
gidargs
,
(
ngargs
+
1
)
*
sizeof
(
*
gidargs
));
if
(
!
newgidargs
){
if
(
!
newgidargs
)
free
(
gidargs
);
goto
out
;
return
-
1
;
}
gidargs
=
newgidargs
;
gidargs
=
newgidargs
;
gidargs
[
ngargs
-
3
]
=
malloc
(
21
);
gidargs
[
ngargs
-
3
]
=
malloc
(
21
);
gidargs
[
ngargs
-
2
]
=
malloc
(
21
);
gidargs
[
ngargs
-
2
]
=
malloc
(
21
);
gidargs
[
ngargs
-
1
]
=
malloc
(
21
);
gidargs
[
ngargs
-
1
]
=
malloc
(
21
);
if
(
!
gidargs
[
ngargs
-
3
]
||
!
gidargs
[
ngargs
-
2
]
||
!
gidargs
[
ngargs
-
1
])
if
(
!
gidargs
[
ngargs
-
3
]
||
!
gidargs
[
ngargs
-
2
]
||
!
gidargs
[
ngargs
-
1
])
return
-
1
;
goto
out
;
sprintf
(
gidargs
[
ngargs
-
3
],
"%ld"
,
m
->
ns_id
);
sprintf
(
gidargs
[
ngargs
-
3
],
"%ld"
,
m
->
ns_id
);
sprintf
(
gidargs
[
ngargs
-
2
],
"%ld"
,
m
->
host_id
);
sprintf
(
gidargs
[
ngargs
-
2
],
"%ld"
,
m
->
host_id
);
sprintf
(
gidargs
[
ngargs
-
1
],
"%ld"
,
m
->
range
);
sprintf
(
gidargs
[
ngargs
-
1
],
"%ld"
,
m
->
range
);
...
@@ -316,17 +316,20 @@ static int map_child_uids(int pid, struct id_map *map)
...
@@ -316,17 +316,20 @@ static int map_child_uids(int pid, struct id_map *map)
}
}
}
}
ret
=
-
2
;
// exec newuidmap
// exec newuidmap
if
(
nuargs
>
2
&&
run_cmd
(
uidargs
)
!=
0
)
{
if
(
nuargs
>
2
&&
run_cmd
(
uidargs
)
!=
0
)
{
fprintf
(
stderr
,
"Error mapping uids
\n
"
);
fprintf
(
stderr
,
"Error mapping uids
\n
"
);
return
-
2
;
goto
out
;
}
}
// exec newgidmap
// exec newgidmap
if
(
ngargs
>
2
&&
run_cmd
(
gidargs
)
!=
0
)
{
if
(
ngargs
>
2
&&
run_cmd
(
gidargs
)
!=
0
)
{
fprintf
(
stderr
,
"Error mapping gids
\n
"
);
fprintf
(
stderr
,
"Error mapping gids
\n
"
);
return
-
2
;
goto
out
;
}
}
ret
=
0
;
out:
for
(
i
=
0
;
i
<
nuargs
;
i
++
)
for
(
i
=
0
;
i
<
nuargs
;
i
++
)
free
(
uidargs
[
i
]);
free
(
uidargs
[
i
]);
for
(
i
=
0
;
i
<
ngargs
;
i
++
)
for
(
i
=
0
;
i
<
ngargs
;
i
++
)
...
@@ -334,7 +337,7 @@ static int map_child_uids(int pid, struct id_map *map)
...
@@ -334,7 +337,7 @@ static int map_child_uids(int pid, struct id_map *map)
free
(
uidargs
);
free
(
uidargs
);
free
(
gidargs
);
free
(
gidargs
);
return
0
;
return
ret
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
...
...
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