プロジェクト

全般

プロフィール

Vote #81521

完了

Race condition (possible filename collision) in Attachment.disk_filename

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Attachments_19
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
19
version_id:
155
issue_org_id:
35539
author_id:
40856
assigned_to_id:
332
comments:
8
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

When two (or more) files with the same name are uploaded at the same time, it may happen that two or more of the resulting attachment records end up using the same disk file, resulting in data loss if the files actually differ in content. This was already previously mentioned in #34479-2 (but was unrelated to that issue and hence got "lost")

The problem is that @Attachment.disk_filename@ finds a non-existant filename, but fails to "claim" this name in the file system while doing so. So nothing stops a parallel process to end up using the same name if it tries to do so before the first process actually creates the file.

This patch, extracted from "Planio":https://plan.io/redmine-hosting , instead tries to create a file directly, with the @File::EXCL@ flag set, catches the error which means 'filename taken already' and retries until the file is created. This way, filenames are guaranteed to be unique by the underlying file system.


journals

--------------------------------------------------------------------------------
Setting the target version to 5.0.0.
--------------------------------------------------------------------------------
Committed the patch. Thank you.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Reopening this issue in order to handle #35720 and #35721.
--------------------------------------------------------------------------------
Go MAEDA wrote:
> Reopening this issue in order to handle #35720 and #35721.

Committed the fixes in r21193 and r21194.
--------------------------------------------------------------------------------


related_issues

relates,Closed,35720,Defect: Binmode specified twice
relates,Closed,35721,Unlink files after they're closed

Admin Redmine さんが約4年前に更新

  • カテゴリAttachments_19 にセット
  • 対象バージョン5.0.0_155 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0