Skip to content

Commit

Permalink
commands_utils: remove stack allocations
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Apr 10, 2019
1 parent 8131f12 commit c8a0e25
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lxc/commands_utils.c
Expand Up @@ -38,6 +38,7 @@
#include "initutils.h"
#include "log.h"
#include "lxclock.h"
#include "memory_utils.h"
#include "monitor.h"
#include "state.h"
#include "utils.h"
Expand Down Expand Up @@ -102,9 +103,9 @@ int lxc_make_abstract_socket_name(char *path, size_t pathlen,
const char *hashed_sock_name,
const char *suffix)
{
__do_free char *tmppath = NULL;
const char *name;
char *offset;
char *tmppath;
size_t len;
size_t tmplen;
uint64_t hash;
Expand Down Expand Up @@ -153,7 +154,7 @@ int lxc_make_abstract_socket_name(char *path, size_t pathlen,

/* ret >= len; lxcpath or name is too long. hash both */
tmplen = strlen(name) + strlen(lxcpath) + 2;
tmppath = alloca(tmplen);
tmppath = must_realloc(NULL, tmplen);
ret = snprintf(tmppath, tmplen, "%s/%s", lxcpath, name);
if (ret < 0 || (size_t)ret >= tmplen) {
ERROR("Failed to create abstract socket name");
Expand Down

0 comments on commit c8a0e25

Please sign in to comment.