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

getFloat allows to read uninitialised memory #46

Closed
weissi opened this issue Aug 12, 2019 · 0 comments · Fixed by #48
Closed

getFloat allows to read uninitialised memory #46

weissi opened this issue Aug 12, 2019 · 0 comments · Fixed by #48
Labels
bug Something isn't working
Projects

Comments

@weissi
Copy link
Contributor

weissi commented Aug 12, 2019

return self.withVeryUnsafeBytes { ptr in

The code above allows to read uninitialised memory. I'd recommend

    func getFloat(index: Int) -> Float? {
        return self.getInteger(at: index, as: UInt32.self).map { Float(bitPattern: $0) }
    }

    func getDouble(index: Int) -> Double? {
        return self.getInteger(at: index, as: UInt64.self).map { Double(bitPattern: $0) }
    }
@tanner0101 tanner0101 added the bug Something isn't working label Aug 12, 2019
@tanner0101 tanner0101 added this to To Do in Vapor 4 via automation Aug 12, 2019
tanner0101 added a commit that referenced this issue Aug 12, 2019
Vapor 4 automation moved this from To Do to Done Aug 12, 2019
tanner0101 added a commit that referenced this issue Aug 12, 2019
* fix string->bytes method, #44

* fix getUUID method, #45

* at label

* better readFloat/Double methods, #46

* remove unused get float/double methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Vapor 4
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants