提交 7eb56dcd 编写于 作者: J John Ferlan

tests: Resolve possible overrun

Coverity noted that each of the fmemopen called used the strlen value
in order to allocate space, but that neglected space for terminating
null string. So just add 1 to the strlen.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 f5c7d889
......@@ -466,12 +466,13 @@ FILE *fopen(const char *path, const char *mode)
if (STREQ(mode, "r")) {
if (allinone)
return fmemopen((void *)procmountsallinone,
strlen(procmountsallinone), mode);
strlen(procmountsallinone) + 1, mode);
else if (logind)
return fmemopen((void *)procmountslogind,
strlen(procmountslogind), mode);
strlen(procmountslogind) + 1, mode);
else
return fmemopen((void *)procmounts, strlen(procmounts), mode);
return fmemopen((void *)procmounts,
strlen(procmounts) + 1, mode);
} else {
errno = EACCES;
return NULL;
......@@ -481,12 +482,13 @@ FILE *fopen(const char *path, const char *mode)
if (STREQ(mode, "r")) {
if (allinone)
return fmemopen((void *)proccgroupsallinone,
strlen(proccgroupsallinone), mode);
strlen(proccgroupsallinone) + 1, mode);
else if (logind)
return fmemopen((void *)proccgroupslogind,
strlen(proccgroupslogind), mode);
strlen(proccgroupslogind) + 1, mode);
else
return fmemopen((void *)proccgroups, strlen(proccgroups), mode);
return fmemopen((void *)proccgroups,
strlen(proccgroups) + 1, mode);
} else {
errno = EACCES;
return NULL;
......@@ -496,12 +498,13 @@ FILE *fopen(const char *path, const char *mode)
if (STREQ(mode, "r")) {
if (allinone)
return fmemopen((void *)procselfcgroupsallinone,
strlen(procselfcgroupsallinone), mode);
strlen(procselfcgroupsallinone) + 1, mode);
else if (logind)
return fmemopen((void *)procselfcgroupslogind,
strlen(procselfcgroupslogind), mode);
strlen(procselfcgroupslogind) + 1, mode);
else
return fmemopen((void *)procselfcgroups, strlen(procselfcgroups), mode);
return fmemopen((void *)procselfcgroups,
strlen(procselfcgroups) + 1, mode);
} else {
errno = EACCES;
return NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册