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

Fix a loop error #20

Closed
zyfdegh opened this issue May 29, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@zyfdegh
Copy link
Contributor

commented May 29, 2017

I think there is a loop error in file openvpn/utils.go,

for i := 0; i < 10000; i++ {
	filePath = directory + "/" + filePrefix + randomString(10, finenameCharset) + fileExtension
	if _, err := os.Stat(filePath); os.IsExist(err) {
		continue
	}
}

This will run 10000 times whenever the temp file exists or not.

I guess your original idea is generating a non-duplicated temp file path , is it?

If so, an else clause is needed and a break should be in the else case.

Or simply

for i := 0; i < 10000; i++ {
	filePath = directory + "/" + filePrefix + randomString(10, finenameCharset) + fileExtension
	if _, err := os.Stat(filePath); os.IsNotExist(err) {
		break
	}
}

@zyfdegh zyfdegh changed the title Use filepath.Join() instead of string concat Use filepath.Join() instead of string concat and a loop err May 29, 2017

@zyfdegh zyfdegh changed the title Use filepath.Join() instead of string concat and a loop err Fix a loop error May 29, 2017

@Waldz Waldz added this to the After ICO milestone May 29, 2017

@Waldz Waldz added the bug label May 29, 2017

@donce

This comment has been minimized.

Copy link
Contributor

commented Jan 5, 2018

PR merged, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.