Skip to content

Bug in DropPathRoot - IndexOutOfBoundsException #56

@TotalInferno

Description

@TotalInferno

There is a bug in DropPathRoot (in WindowsPathUtils.cs / ICSharpCode.SharpZipLib.Core.WindowsPathUtils) that causes an IndexOutOfBoundsException:

This can be seen for paths such as "\server". It works correctly (as it is) for paths such as "\server\share".

is:

// Scan for two separate elements \\machine\share\restofpath
while ((index <= path.Length) &&
    (((path[index] != '\\') && (path[index] != '/')) || (--elements > 0))) {
    index++;
}

should likely be (but I think other modifications will be needed as well to obtain desired behavior):

// Scan for two separate elements \\machine\share\restofpath
while ((index < path.Length) &&
    (((path[index] != '\\') && (path[index] != '/')) || (--elements > 0))) {
    index++;
}

Also, since "index" starts at 2, a few lines above, I'm not sure what the purpose of "elements" is -- possibly a left over?

Thoughts?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions