mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-09 11:20:59 +00:00
coverity: ensure string is null terminated, return in
error case Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
2d4bcb9615
commit
a2eea3c197
@ -1160,10 +1160,11 @@ static int update_name_and_paths(const char *path, struct lxc_container *oldc,
|
|||||||
SYSERROR("rewinding old config");
|
SYSERROR("rewinding old config");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
contents = malloc(flen);
|
contents = malloc(flen+1);
|
||||||
if (!contents) {
|
if (!contents) {
|
||||||
SYSERROR("out of memory");
|
SYSERROR("out of memory");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
if (fread(contents, 1, flen, f) != flen) {
|
if (fread(contents, 1, flen, f) != flen) {
|
||||||
free(contents);
|
free(contents);
|
||||||
@ -1171,6 +1172,7 @@ static int update_name_and_paths(const char *path, struct lxc_container *oldc,
|
|||||||
SYSERROR("reading old config");
|
SYSERROR("reading old config");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
contents[flen] = '\0';
|
||||||
if (fclose(f) < 0) {
|
if (fclose(f) < 0) {
|
||||||
free(contents);
|
free(contents);
|
||||||
SYSERROR("closing old config");
|
SYSERROR("closing old config");
|
||||||
|
Loading…
Reference in New Issue
Block a user