Opened 10 years ago

Closed 10 years ago

#3186 closed bug (fixed)

BDirectory::Contains() is broken for certain cases of similar paths

Reported by: anevilyak Owned by: axeld
Priority: normal Milestone: R1
Component: Kits/Storage Kit Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description (last modified by anevilyak)

Steps to reproduce:

  1. Create a directory called New Folder.
  2. Create a directory called New Folder 2.
  3. Get a BDirectory object for New Folder, a BEntry for New Folder 2, and call BDirectory::Contains() on the resulting entry. It will (incorrectly) return true, because Contains currently compares the paths of the two up to the length of the directory itself. Attached please find a patch intended to fix the situation by comparing the path components individually.

Attachments (1)

dir.contains.diff (1.3 KB) - added by anevilyak 10 years ago.
Proposed fix for Contains() issues.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 10 years ago by anevilyak

Description: modified (diff)

comment:2 Changed 10 years ago by anevilyak

Description: modified (diff)

comment:3 Changed 10 years ago by anevilyak

On second thought, that patch is flawed also, give me some time to rework.

Changed 10 years ago by anevilyak

Attachment: dir.contains.diff added

Proposed fix for Contains() issues.

comment:4 Changed 10 years ago by anevilyak

Updated patch attached, let me know if you see any problems with it, or perhaps a better way to accomplish it, otherwise I can commit that.

comment:5 Changed 10 years ago by axeld

Isn't that a bit too complicated? I think all that's missing is a check if the other path actually ends at that point, ie. has a '/' at that position or not.

comment:6 Changed 10 years ago by anevilyak

Resolution: fixed
Status: newclosed

Indeed, you're right, thanks for reviewing! Sometimes it's easy to miss the obvious :) Fixed in hrev28754.

Note: See TracTickets for help on using tickets.