From 784263e28ac2f0843da8fb5ab6d1cd7a9381d5a8 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Fri, 10 Dec 2010 15:26:27 +0000 Subject: [PATCH] Fixed a bug that would have considered /boot/trashy_file be in /boot/trash. Spotted by Rene, thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39805 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/mail/DeskbarView.cpp | 15 +++++++++------ src/servers/mail/main.cpp | 11 +++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/servers/mail/DeskbarView.cpp b/src/servers/mail/DeskbarView.cpp index d52dbc4904..59961f050b 100644 --- a/src/servers/mail/DeskbarView.cpp +++ b/src/servers/mail/DeskbarView.cpp @@ -131,13 +131,16 @@ bool DeskbarView::_EntryInTrash(const entry_ref* entry) BPath trashPath; BPath entryPath(entry); BVolume volume(entry->device); - if (volume.InitCheck() == B_OK) { - find_directory(B_TRASH_DIRECTORY, &trashPath, false, &volume); - if (strncmp(entryPath.Path(), trashPath.Path(), - strlen(trashPath.Path())) == 0) + if (volume.InitCheck() == B_OK + && find_directory(B_TRASH_DIRECTORY, &trashPath, false, + &volume) == B_OK) { + char path[PATH_MAX]; + strncpy(path, trashPath.Path(), sizeof(path)); + strncat(path, "/", sizeof(path)); + if (strncmp(entryPath.Path(), path, strlen(path)) == 0) return true; } - + return false; } @@ -252,7 +255,7 @@ DeskbarView::MessageReceived(BMessage* message) int32 what; dev_t device; ino_t directory; - const char *name; + const char *name; entry_ref ref; message->FindInt32("opcode", &what); message->FindInt32("device", &device); diff --git a/src/servers/mail/main.cpp b/src/servers/mail/main.cpp index 9d59c7bd71..d901c38983 100644 --- a/src/servers/mail/main.cpp +++ b/src/servers/mail/main.cpp @@ -638,10 +638,13 @@ MailDaemonApp::_IsEntryInTrash(BEntry& entry) BPath trashPath; BPath entryPath(&entry); BVolume volume(ref.device); - if (volume.InitCheck() == B_OK) { - find_directory(B_TRASH_DIRECTORY, &trashPath, false, &volume); - if (strncmp(entryPath.Path(), trashPath.Path(), - strlen(trashPath.Path())) == 0) + if (volume.InitCheck() == B_OK + && find_directory(B_TRASH_DIRECTORY, &trashPath, + false, &volume) == B_OK) { + char path[PATH_MAX]; + strncpy(path, trashPath.Path(), sizeof(path)); + strncat(path, "/", sizeof(path)); + if (strncmp(entryPath.Path(), path, strlen(path)) == 0) return true; }