From f3c45c52ad512b31d84f8254b7ad228aa4e0bab9 Mon Sep 17 00:00:00 2001 From: Crementif <26669564+Crementif@users.noreply.github.com> Date: Sun, 4 Sep 2022 19:42:48 +0200 Subject: [PATCH] Fix possible race condition in fsa_dirnext Also some minor line changes to make em match a bit better! --- source/devoptab/devoptab_fsa_dirnext.cpp | 5 ++--- source/devoptab/devoptab_fsa_fsync.cpp | 3 +-- source/devoptab/devoptab_fsa_seek.cpp | 3 +-- source/devoptab/devoptab_fsa_truncate.cpp | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/source/devoptab/devoptab_fsa_dirnext.cpp b/source/devoptab/devoptab_fsa_dirnext.cpp index f9eeaa7..07ba3ab 100644 --- a/source/devoptab/devoptab_fsa_dirnext.cpp +++ b/source/devoptab/devoptab_fsa_dirnext.cpp @@ -13,12 +13,11 @@ int __fsa_dirnext(struct _reent *r, return -1; } - auto *dir = (__fsa_dir_t *) (dirState->dirStruct); - memset(&dir->entry_data, 0, sizeof(dir->entry_data)); - auto *deviceData = (FSADeviceData *) r->deviceData; + auto *dir = (__fsa_dir_t *) (dirState->dirStruct); std::lock_guard lock(dir->mutex); + memset(&dir->entry_data, 0, sizeof(dir->entry_data)); status = FSAReadDir(deviceData->clientHandle, dir->fd, &dir->entry_data); if (status < 0) { diff --git a/source/devoptab/devoptab_fsa_fsync.cpp b/source/devoptab/devoptab_fsa_fsync.cpp index 885a71e..3850391 100644 --- a/source/devoptab/devoptab_fsa_fsync.cpp +++ b/source/devoptab/devoptab_fsa_fsync.cpp @@ -11,8 +11,7 @@ int __fsa_fsync(struct _reent *r, return -1; } - auto *file = (__fsa_file_t *) fd; - + auto *file = (__fsa_file_t *) fd; auto *deviceData = (FSADeviceData *) r->deviceData; std::lock_guard lock(file->mutex); diff --git a/source/devoptab/devoptab_fsa_seek.cpp b/source/devoptab/devoptab_fsa_seek.cpp index 69b0a6b..74b2bb5 100644 --- a/source/devoptab/devoptab_fsa_seek.cpp +++ b/source/devoptab/devoptab_fsa_seek.cpp @@ -15,8 +15,7 @@ off_t __fsa_seek(struct _reent *r, return -1; } - auto *file = (__fsa_file_t *) fd; - + auto *file = (__fsa_file_t *) fd; auto *deviceData = (FSADeviceData *) r->deviceData; std::lock_guard lock(file->mutex); diff --git a/source/devoptab/devoptab_fsa_truncate.cpp b/source/devoptab/devoptab_fsa_truncate.cpp index 6c617d8..562ee72 100644 --- a/source/devoptab/devoptab_fsa_truncate.cpp +++ b/source/devoptab/devoptab_fsa_truncate.cpp @@ -13,8 +13,7 @@ int __fsa_ftruncate(struct _reent *r, return -1; } - auto *file = (__fsa_file_t *) fd; - + auto *file = (__fsa_file_t *) fd; auto *deviceData = (FSADeviceData *) r->deviceData; std::lock_guard lock(file->mutex);