Make sure that enough bytes exist for file name of temporary file which
is used to construct the next database file.
While at it, use a better variable name.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
commonio_close(struct commonio_db *db, MAYBE_UNUSED bool process_selinux)
{
bool errors = false;
- char buf[1024];
+ char tmpf[PATH_MAX];
struct stat sb;
if (!db->isopen) {
sb.st_gid = db->st_gid;
}
- if (stprintf_a(buf, "%s.cioXXXXXX", db->filename) == -1)
+ if (stprintf_a(tmpf, "%s.cioXXXXXX", db->filename) == -1)
goto fail;
#ifdef WITH_SELINUX
}
#endif
- db->fp = fmkstemp_set_perms(buf, &sb);
+ db->fp = fmkstemp_set_perms(tmpf, &sb);
if (NULL == db->fp) {
goto fail;
}
db->fp = NULL;
if (errors) {
- unlink (buf);
+ unlink(tmpf);
goto fail;
}
- if (lrename(buf, db->filename) != 0) {
+ if (lrename(tmpf, db->filename) != 0) {
goto fail;
}