From 8aea762e7a0013d81a798e6c375b7a9497a4e7e4 Mon Sep 17 00:00:00 2001 From: Lephe Date: Mon, 10 Jan 2022 13:38:28 +0100 Subject: [PATCH] fs: use a static variable in calls to BFile_Create() There is no evidence that BFile_Create() keeps the address and writes to it later on, but I'd rather be overly careful than have to debug a stack corruption problem in half a year :) --- src/fs/fugue/fugue_open.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fs/fugue/fugue_open.c b/src/fs/fugue/fugue_open.c index e1c4684..7c48ebd 100644 --- a/src/fs/fugue/fugue_open.c +++ b/src/fs/fugue/fugue_open.c @@ -6,7 +6,7 @@ #include "util.h" #include "fugue.h" -/* TODO: fugue_open(): Handle trailing '/' and filesystem root */ +static int new_file_size; int fugue_open(char const *path, int flags, GUNUSED mode_t mode) { @@ -91,8 +91,8 @@ int fugue_open(char const *path, int flags, GUNUSED mode_t mode) /* If the file does not exist and O_CREAT is set, create it */ if((flags & O_CREAT) && ((flags & O_TRUNC) || fugue_fd < 0)) { - int size = 0; - err = BFile_Create(fcpath, BFile_File, &size); + new_file_size = 0; + err = BFile_Create(fcpath, BFile_File, &new_file_size); if(err < 0) { errno = bfile_error_to_errno(err); rc = -1;