From 528b69d508b5e6670ecc932ecf36378bbd986fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 24 Oct 2008 10:36:43 +0000 Subject: [PATCH] * Fixed bug #2727: symlinks usually "abuse" the data stream part of a bfs_inode to store the link path (up to a certain length). If this was long enough to clobber the data_stream::size field (which luckily was the last field of struct data_stream), Inode::Free() would mistakenly assume this to be a valid data stream to be freed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28311 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Inode.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index 89fc99e626..1e0b25d8a8 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -2151,9 +2151,11 @@ Inode::Free(Transaction& transaction) // Perhaps there should be an implementation of Inode::ShrinkStream() that // just frees the data_stream, but doesn't change the inode (since it is // freed anyway) - that would make an undelete command possible - status_t status = SetFileSize(transaction, 0); - if (status < B_OK) - return status; + if (!IsSymLink() || (Flags() & INODE_LONG_SYMLINK) != 0) { + status_t status = SetFileSize(transaction, 0); + if (status < B_OK) + return status; + } // Free all attributes, and remove their indices { @@ -2165,7 +2167,7 @@ Inode::Free(Transaction& transaction) uint32 type; size_t length; ino_t id; - while ((status = iterator.GetNext(name, &length, &type, &id)) == B_OK) { + while (iterator.GetNext(name, &length, &type, &id) == B_OK) { RemoveAttribute(transaction, name); } }