Skip to content

Commit c745eea

Browse files
stoeckmannalejandro-colomar
authored andcommitted
lib/commonio.c: Larger buffer size for file names
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 <[email protected]>
1 parent f8732b1 commit c745eea

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/commonio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ int
872872
commonio_close(struct commonio_db *db, MAYBE_UNUSED bool process_selinux)
873873
{
874874
bool errors = false;
875-
char buf[1024];
875+
char tmpf[PATH_MAX];
876876
struct stat sb;
877877

878878
if (!db->isopen) {
@@ -937,7 +937,7 @@ commonio_close(struct commonio_db *db, MAYBE_UNUSED bool process_selinux)
937937
sb.st_gid = db->st_gid;
938938
}
939939

940-
if (stprintf_a(buf, "%s.cioXXXXXX", db->filename) == -1)
940+
if (stprintf_a(tmpf, "%s.cioXXXXXX", db->filename) == -1)
941941
goto fail;
942942

943943
#ifdef WITH_SELINUX
@@ -947,7 +947,7 @@ commonio_close(struct commonio_db *db, MAYBE_UNUSED bool process_selinux)
947947
}
948948
#endif
949949

950-
db->fp = fmkstemp_set_perms(buf, &sb);
950+
db->fp = fmkstemp_set_perms(tmpf, &sb);
951951
if (NULL == db->fp) {
952952
goto fail;
953953
}
@@ -971,11 +971,11 @@ commonio_close(struct commonio_db *db, MAYBE_UNUSED bool process_selinux)
971971
db->fp = NULL;
972972

973973
if (errors) {
974-
unlink (buf);
974+
unlink(tmpf);
975975
goto fail;
976976
}
977977

978-
if (lrename(buf, db->filename) != 0) {
978+
if (lrename(tmpf, db->filename) != 0) {
979979
goto fail;
980980
}
981981

0 commit comments

Comments
 (0)