From 4d201a526430b5d5c24d8aca1d079c1a9f77720e Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Tue, 9 Jul 2024 03:33:11 +0300 Subject: [PATCH] Fix memory corruption in USTAR::SymLink --- storage/fs/ustar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/fs/ustar.cpp b/storage/fs/ustar.cpp index 29a458bb..671a54a9 100644 --- a/storage/fs/ustar.cpp +++ b/storage/fs/ustar.cpp @@ -341,8 +341,9 @@ namespace vfs if (ret < 0) return ret; - USTARInode *node = (USTARInode *)Result; - strncpy(node->Header->link, Target, sizeof(node->Header->link)); + USTARInode *node = (USTARInode *)*Result; + FileHeader *hdr = node->Header; + strncpy(hdr->link, Target, MIN(sizeof(hdr->link) - 1, strlen(Target))); return 0; }