lxccontainer: config_file_exists()

parent 238b3e5e
...@@ -113,12 +113,15 @@ static bool do_lxcapi_save_config(struct lxc_container *c, const char *alt_file) ...@@ -113,12 +113,15 @@ static bool do_lxcapi_save_config(struct lxc_container *c, const char *alt_file)
static bool config_file_exists(const char *lxcpath, const char *cname) static bool config_file_exists(const char *lxcpath, const char *cname)
{ {
/* $lxcpath + '/' + $cname + '/config' + \0 */ int ret;
int ret, len = strlen(lxcpath) + strlen(cname) + 9; size_t len;
char *fname = alloca(len); char *fname;
/* $lxcpath + '/' + $cname + '/config' + \0 */
len = strlen(lxcpath) + strlen(cname) + 9;
fname = alloca(len);
ret = snprintf(fname, len, "%s/%s/config", lxcpath, cname); ret = snprintf(fname, len, "%s/%s/config", lxcpath, cname);
if (ret < 0 || ret >= len) if (ret < 0 || (size_t)ret >= len)
return false; return false;
return file_exists(fname); return file_exists(fname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment