Skip to content

Bug in DropPathRoot - IndexOutOfBoundsException #56

Closed

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions