Skip to content

1.52.2 - Fix arithmetic overflow crash in request pagination

Latest
Compare
Choose a tag to compare
@penny-for-vapor penny-for-vapor released this 08 May 23:09
8baacd7

What's Changed

Fix arithmetic overflow crash in request pagination by @petrpavlik in #637

When paging request, providing large values for page and per params will cause an arithmetic overflow exception and crash the process

Fixes a crash where trying to paginate with values that when multiplied cause an arithmetic overflow exception and crash the process. Following added unit tests provides an example.

    func testPaginationDoesntCrashOnOverflow() throws {
        let db = DummyDatabaseForTestSQLSerializer()
        let pageRequest1 = PageRequest(page: 1184467440737095516, per: 1184467440737095516)
        db.fakedRows.append([.init(["aggregate": 1])])
        // This would crash on `Swift runtime failure: arithmetic overflow` if not handled
        // so no point trying any XCTAssert
        _ = try Planet2
            .query(on: db)
            .paginate(pageRequest1)
            .wait()
    }
This patch was released by @gwynne

Full Changelog: 1.52.1...1.52.2