Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error adding same hostname if it is the last in the previous entry #3

Closed
areYouLazy opened this issue Feb 3, 2021 · 1 comment
Closed

Comments

@areYouLazy
Copy link
Owner

Let's say I've an entry like:
1.1.1.1 my.dns

If I add an entry like
2.2.2.2 my.dns

the library goes in out-of-bound trying to remove the hostname from the previous entry
This goes well if the 1st entry has more than 1 hostname, like
1.1.1.1 my.dns my.second.dns

@areYouLazy
Copy link
Owner Author

The problem should be here

h.HostsFileLines[idx].Hostnames = append(h.HostsFileLines[idx].Hostnames[:hostIdx], h.HostsFileLines[idx].Hostnames[hostIdx+1:]...)

We need to check if it's the last entry before removing it using the append() method

areYouLazy added a commit that referenced this issue Feb 3, 2021
#3 this should fix the out-of-bound error on last hostname removal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant