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
6db96171
Unverified
Commit
6db96171
authored
Mar 17, 2017
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python3: Deal with potential NULL char*
Closes #1466 Signed-off-by:
Stéphane Graber
<
stgraber@ubuntu.com
>
parent
3bd24f75
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
7 deletions
+53
-7
lxc.c
src/python-lxc/lxc.c
+53
-7
No files found.
src/python-lxc/lxc.c
View file @
6db96171
...
@@ -353,7 +353,14 @@ LXC_get_global_config_item(PyObject *self, PyObject *args, PyObject *kwds)
...
@@ -353,7 +353,14 @@ LXC_get_global_config_item(PyObject *self, PyObject *args, PyObject *kwds)
static
PyObject
*
static
PyObject
*
LXC_get_version
(
PyObject
*
self
,
PyObject
*
args
)
LXC_get_version
(
PyObject
*
self
,
PyObject
*
args
)
{
{
return
PyUnicode_FromString
(
lxc_get_version
());
const
char
*
rv
=
NULL
;
rv
=
lxc_get_version
();
if
(
!
rv
)
{
return
PyUnicode_FromString
(
""
);
}
return
PyUnicode_FromString
(
rv
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -407,6 +414,10 @@ LXC_list_containers(PyObject *self, PyObject *args, PyObject *kwds)
...
@@ -407,6 +414,10 @@ LXC_list_containers(PyObject *self, PyObject *args, PyObject *kwds)
/* Generate the tuple */
/* Generate the tuple */
list
=
PyTuple_New
(
list_count
);
list
=
PyTuple_New
(
list_count
);
for
(
i
=
0
;
i
<
list_count
;
i
++
)
{
for
(
i
=
0
;
i
<
list_count
;
i
++
)
{
if
(
!
names
[
i
])
{
continue
;
}
PyTuple_SET_ITEM
(
list
,
i
,
PyUnicode_FromString
(
names
[
i
]));
PyTuple_SET_ITEM
(
list
,
i
,
PyUnicode_FromString
(
names
[
i
]));
free
(
names
[
i
]);
free
(
names
[
i
]);
}
}
...
@@ -451,7 +462,7 @@ Container_init(Container *self, PyObject *args, PyObject *kwds)
...
@@ -451,7 +462,7 @@ Container_init(Container *self, PyObject *args, PyObject *kwds)
Py_XDECREF
(
fs_config_path
);
Py_XDECREF
(
fs_config_path
);
PyErr_Format
(
PyExc_RuntimeError
,
"%s:%s:%d: error during init for container '%s'."
,
PyErr_Format
(
PyExc_RuntimeError
,
"%s:%s:%d: error during init for container '%s'."
,
__FUNCTION__
,
__FILE__
,
__LINE__
,
name
);
__FUNCTION__
,
__FILE__
,
__LINE__
,
name
);
return
-
1
;
return
-
1
;
}
}
...
@@ -473,8 +484,14 @@ Container_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -473,8 +484,14 @@ Container_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static
PyObject
*
static
PyObject
*
Container_config_file_name
(
Container
*
self
,
void
*
closure
)
Container_config_file_name
(
Container
*
self
,
void
*
closure
)
{
{
return
PyUnicode_FromString
(
char
*
rv
=
NULL
;
self
->
container
->
config_file_name
(
self
->
container
));
rv
=
self
->
container
->
config_file_name
(
self
->
container
);
if
(
!
rv
)
{
return
PyUnicode_FromString
(
""
);
}
return
PyUnicode_FromString
(
rv
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -506,6 +523,10 @@ Container_init_pid(Container *self, void *closure)
...
@@ -506,6 +523,10 @@ Container_init_pid(Container *self, void *closure)
static
PyObject
*
static
PyObject
*
Container_name
(
Container
*
self
,
void
*
closure
)
Container_name
(
Container
*
self
,
void
*
closure
)
{
{
if
(
!
self
->
container
->
name
)
{
return
PyUnicode_FromString
(
""
);
}
return
PyUnicode_FromString
(
self
->
container
->
name
);
return
PyUnicode_FromString
(
self
->
container
->
name
);
}
}
...
@@ -522,7 +543,15 @@ Container_running(Container *self, void *closure)
...
@@ -522,7 +543,15 @@ Container_running(Container *self, void *closure)
static
PyObject
*
static
PyObject
*
Container_state
(
Container
*
self
,
void
*
closure
)
Container_state
(
Container
*
self
,
void
*
closure
)
{
{
return
PyUnicode_FromString
(
self
->
container
->
state
(
self
->
container
));
const
char
*
rv
=
NULL
;
rv
=
self
->
container
->
state
(
self
->
container
);
if
(
!
rv
)
{
return
PyUnicode_FromString
(
""
);
}
return
PyUnicode_FromString
(
rv
);
}
}
/* Container Functions */
/* Container Functions */
...
@@ -946,8 +975,15 @@ Container_get_config_item(Container *self, PyObject *args, PyObject *kwds)
...
@@ -946,8 +975,15 @@ Container_get_config_item(Container *self, PyObject *args, PyObject *kwds)
static
PyObject
*
static
PyObject
*
Container_get_config_path
(
Container
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
Container_get_config_path
(
Container
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
{
return
PyUnicode_FromString
(
const
char
*
rv
=
NULL
;
self
->
container
->
get_config_path
(
self
->
container
));
rv
=
self
->
container
->
get_config_path
(
self
->
container
);
if
(
!
rv
)
{
return
PyUnicode_FromString
(
""
);
}
return
PyUnicode_FromString
(
rv
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1011,6 +1047,11 @@ Container_get_interfaces(Container *self)
...
@@ -1011,6 +1047,11 @@ Container_get_interfaces(Container *self)
/* Add the entries to the tuple and free the memory */
/* Add the entries to the tuple and free the memory */
i
=
0
;
i
=
0
;
while
(
interfaces
[
i
])
{
while
(
interfaces
[
i
])
{
if
(
!
interfaces
[
i
])
{
i
++
;
continue
;
}
PyObject
*
unicode
=
PyUnicode_FromString
(
interfaces
[
i
]);
PyObject
*
unicode
=
PyUnicode_FromString
(
interfaces
[
i
]);
if
(
!
unicode
)
{
if
(
!
unicode
)
{
Py_DECREF
(
ret
);
Py_DECREF
(
ret
);
...
@@ -1066,6 +1107,11 @@ Container_get_ips(Container *self, PyObject *args, PyObject *kwds)
...
@@ -1066,6 +1107,11 @@ Container_get_ips(Container *self, PyObject *args, PyObject *kwds)
/* Add the entries to the tuple and free the memory */
/* Add the entries to the tuple and free the memory */
i
=
0
;
i
=
0
;
while
(
ips
[
i
])
{
while
(
ips
[
i
])
{
if
(
!
ips
[
i
])
{
i
++
;
continue
;
}
PyObject
*
unicode
=
PyUnicode_FromString
(
ips
[
i
]);
PyObject
*
unicode
=
PyUnicode_FromString
(
ips
[
i
]);
if
(
!
unicode
)
{
if
(
!
unicode
)
{
Py_DECREF
(
ret
);
Py_DECREF
(
ret
);
...
...
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