]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't parent temporary dir buffer to ef in exfile_open_mkdir (#5823) master
authorEthan Thompson <77711716+ethan-thompson@users.noreply.github.com>
Mon, 13 Apr 2026 18:25:29 +0000 (14:25 -0400)
committerGitHub <noreply@github.com>
Mon, 13 Apr 2026 18:25:29 +0000 (14:25 -0400)
The buffer is always freed before the function returns, so parenting
it to ef implied a lifetime relationship that didn't exist.

Signed-off-by: ethan-thompson <ethan.thompson@networkradius.com>
src/lib/server/exfile.c

index 25ab67fcfc05b3b5d5bfa1c016a174ac911bf9a8..5c0aa33d85e2f1e8029f9382aaa83a808385948f 100644 (file)
@@ -234,7 +234,7 @@ void exfile_enable_triggers(exfile_t *ef, CONF_SECTION *conf, char const *trigge
  *     Try to open the file. It it doesn't exist, try to
  *     create it's parent directories.
  */
-static int exfile_open_mkdir(exfile_t *ef, char const *filename, mode_t permissions, int flags)
+static int exfile_open_mkdir(char const *filename, mode_t permissions, int flags)
 {
        int fd;
 
@@ -248,7 +248,7 @@ static int exfile_open_mkdir(exfile_t *ef, char const *filename, mode_t permissi
                 *      Maybe the directory doesn't exist.  Try to
                 *      create it.
                 */
-               dir = talloc_strdup(ef, filename);
+               dir = talloc_strdup(NULL, filename);
                if (!dir) return -1;
                p = strrchr(dir, FR_DIR_SEP);
                if (!p) {
@@ -407,7 +407,7 @@ reopen_reset:
        ef->entries[i].fd = -1;
 
 reopen:
-       ef->entries[i].fd = exfile_open_mkdir(ef, filename, permissions, flags);
+       ef->entries[i].fd = exfile_open_mkdir(filename, permissions, flags);
        if (ef->entries[i].fd < 0) goto error;
 
        exfile_trigger(ef, &ef->entries[i], EXFILE_TRIGGER_OPEN);
@@ -531,7 +531,7 @@ int exfile_open(exfile_t *ef, char const *filename, mode_t permissions, int flag
        if (!ef || !filename) return -1;
 
        if (!ef->locking) {
-               int found = exfile_open_mkdir(ef, filename, permissions, flags);
+               int found = exfile_open_mkdir(filename, permissions, flags);
                off_t real_offset;
 
                if (found < 0) return -1;