Skip to content

Out of range exception on system without a WINS configuration #105991

@mgirard1mtx

Description

@mgirard1mtx

A system may be without a WINS option at line 134 we should check if the index return is -1.

int labelIndex = fileContents.IndexOf(label);
int labelLineStart = fileContents.LastIndexOf(Environment.NewLine, labelIndex, StringComparison.Ordinal);

Exemple of exception:

{System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'startIndex')
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)}

Where the labelIndex was -1 in ParseWinsServerAddressesFromSmbConfFile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Nethelp wanted[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions