Opened 15 years ago

Closed 15 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:
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 15 years ago.
Proposed fix for Contains() issues.

Download all attachments as: .zip

Change History (7)

comment:1 by anevilyak, 15 years ago

Description: modified (diff)

comment:2 by anevilyak, 15 years ago

Description: modified (diff)

comment:3 by anevilyak, 15 years ago

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

by anevilyak, 15 years ago

Attachment: dir.contains.diff added

Proposed fix for Contains() issues.

comment:4 by anevilyak, 15 years ago

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 by axeld, 15 years ago

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 by anevilyak, 15 years ago

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.