mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-07 00:42:51 +00:00
commands: avoid NULL pointer dereference
lxc_cmd_get_lxcpath() and lxc_cmd_get_name() both pass a nil pointer to fill_sock_name(). Make sure that they are not dereferenced. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
caf3beb02d
commit
c54a4aeeb5
@ -74,14 +74,19 @@
|
|||||||
|
|
||||||
lxc_log_define(lxc_commands, lxc);
|
lxc_log_define(lxc_commands, lxc);
|
||||||
|
|
||||||
static int fill_sock_name(char *path, int len, const char *name,
|
static int fill_sock_name(char *path, int len, const char *lxcname,
|
||||||
const char *lxcpath, const char *hashed_sock_name)
|
const char *lxcpath, const char *hashed_sock_name)
|
||||||
{
|
{
|
||||||
|
const char *name;
|
||||||
char *tmppath;
|
char *tmppath;
|
||||||
size_t tmplen;
|
size_t tmplen;
|
||||||
uint64_t hash;
|
uint64_t hash;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
name = lxcname;
|
||||||
|
if (!name)
|
||||||
|
name = "";
|
||||||
|
|
||||||
if (hashed_sock_name != NULL) {
|
if (hashed_sock_name != NULL) {
|
||||||
ret = snprintf(path, len, "lxc/%s/command", hashed_sock_name);
|
ret = snprintf(path, len, "lxc/%s/command", hashed_sock_name);
|
||||||
if (ret < 0 || ret >= len) {
|
if (ret < 0 || ret >= len) {
|
||||||
|
Loading…
Reference in New Issue
Block a user