mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 07:19:16 +00:00
coverity: #1425859
check return value of snprintf() Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
d5590c8c70
commit
e8eb39565a
@ -717,10 +717,12 @@ char *lxc_deslashify(const char *path)
|
|||||||
|
|
||||||
char *lxc_append_paths(const char *first, const char *second)
|
char *lxc_append_paths(const char *first, const char *second)
|
||||||
{
|
{
|
||||||
size_t len = strlen(first) + strlen(second) + 1;
|
int ret;
|
||||||
const char *pattern = "%s%s";
|
size_t len;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
const char *pattern = "%s%s";
|
||||||
|
|
||||||
|
len = strlen(first) + strlen(second) + 1;
|
||||||
if (second[0] != '/') {
|
if (second[0] != '/') {
|
||||||
len += 1;
|
len += 1;
|
||||||
pattern = "%s/%s";
|
pattern = "%s/%s";
|
||||||
@ -730,7 +732,12 @@ char *lxc_append_paths(const char *first, const char *second)
|
|||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
snprintf(result, len, pattern, first, second);
|
ret = snprintf(result, len, pattern, first, second);
|
||||||
|
if (ret < 0 || (size_t)ret >= len) {
|
||||||
|
free(result);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user