]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/commonio.c: Larger buffer size for file names
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 12 Jan 2026 17:29:54 +0000 (18:29 +0100)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Wed, 14 Jan 2026 12:05:45 +0000 (13:05 +0100)
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>
lib/commonio.c

index dd528a1af2b057905b8b1ee6702d66ca9ef0e291..777795661c10348c264312ef26717acd2cea3abb 100644 (file)
@@ -872,7 +872,7 @@ int
 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) {
@@ -937,7 +937,7 @@ commonio_close(struct commonio_db *db, MAYBE_UNUSED bool process_selinux)
                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
@@ -947,7 +947,7 @@ commonio_close(struct commonio_db *db, MAYBE_UNUSED bool process_selinux)
        }
 #endif
 
-       db->fp = fmkstemp_set_perms(buf, &sb);
+       db->fp = fmkstemp_set_perms(tmpf, &sb);
        if (NULL == db->fp) {
                goto fail;
        }
@@ -971,11 +971,11 @@ commonio_close(struct commonio_db *db, MAYBE_UNUSED bool process_selinux)
        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;
        }