Ticket #3186 (closed bug: fixed)

Opened 16 months ago

Last modified 16 months ago

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: Platform: All
Blocking:

Description (last modified by anevilyak) (diff)

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

dir.contains.diff Download (1.3 KB) - added by anevilyak 16 months ago.
Proposed fix for Contains() issues.

Change History

Changed 16 months ago by anevilyak

  • description modified (diff)

Changed 16 months ago by anevilyak

  • description modified (diff)

Changed 16 months ago by anevilyak

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

Changed 16 months ago by anevilyak

Proposed fix for Contains() issues.

Changed 16 months 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.

Changed 16 months 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.

Changed 16 months ago by anevilyak

  • status changed from new to closed
  • resolution set to fixed

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

Note: See TracTickets for help on using tickets.