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 panic in HAR conversion due to missing length check #760

Merged
merged 3 commits into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions converter/har/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,15 @@ func Convert(h HAR, options lib.Options, minSleep, maxSleep uint, enableChecks b
} else {
// Add sleep time at the end of the group
nextPage := pages[i+1]
lastEntry := entries[len(entries)-1]
t := nextPage.StartedDateTime.Sub(lastEntry.StartedDateTime).Seconds()
if t < 0.01 {
t = 0.5
sleepTime := 0.5
if len(entries) > 0 {
lastEntry := entries[len(entries)-1]
t := nextPage.StartedDateTime.Sub(lastEntry.StartedDateTime).Seconds()
if t >= 0.01 {
sleepTime = t
}
}
fprintf(w, "\t\tsleep(%.2f);\n", t)
fprintf(w, "\t\tsleep(%.2f);\n", sleepTime)
}
}

Expand Down
3 changes: 2 additions & 1 deletion release notes/upcoming.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ Thanks to @sherrman for reporting the binary handling issues that prompted the a
* UI: Password input is now masked in `k6 login influxdb` and `k6 login cloud`. (#734)
* Config: Environment variables can now be used to modify k6's behavior in the `k6 login` subcommands. (#734)
* HTTP: Binary response bodies were mangled because there was no way to avoid converting them to UTF-16 JavaScript strings. (#749)
* Config: Stages were appended instead of overwritten from upper config "tiers", and were doubled when supplied via the CLI flag (#759)
* Config: Stages were appended instead of overwritten from upper config "tiers", and were doubled when supplied via the CLI flag (#759)
* HAR converter: Fixed a panic due to a missing array length check (#760)