mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-03 15:39:18 +00:00
Suppress hardcoded table sizes
. Use sizeof() instead of hardcoded values . snprintf(..., size, ""...) is in error if the return code is >= size (not sufficient to set only ">") Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
This commit is contained in:
parent
9b01795886
commit
6da7363420
@ -1171,8 +1171,8 @@ int safe_mount(const char *src, const char *dest, const char *fstype,
|
|||||||
if (srcfd < 0)
|
if (srcfd < 0)
|
||||||
return srcfd;
|
return srcfd;
|
||||||
|
|
||||||
ret = snprintf(srcbuf, 50, "/proc/self/fd/%d", srcfd);
|
ret = snprintf(srcbuf, sizeof(srcbuf), "/proc/self/fd/%d", srcfd);
|
||||||
if (ret < 0 || ret > 50) {
|
if (ret < 0 || ret >= (int)sizeof(srcbuf)) {
|
||||||
close(srcfd);
|
close(srcfd);
|
||||||
ERROR("Out of memory");
|
ERROR("Out of memory");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -1191,8 +1191,8 @@ int safe_mount(const char *src, const char *dest, const char *fstype,
|
|||||||
return destfd;
|
return destfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = snprintf(destbuf, 50, "/proc/self/fd/%d", destfd);
|
ret = snprintf(destbuf, sizeof(destbuf), "/proc/self/fd/%d", destfd);
|
||||||
if (ret < 0 || ret > 50) {
|
if (ret < 0 || ret >= (int)sizeof(destbuf)) {
|
||||||
if (srcfd != -1)
|
if (srcfd != -1)
|
||||||
close(srcfd);
|
close(srcfd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user