mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-05 09:20:29 +00:00
Finish writing documentation, fix segfaults?
This commit is contained in:
parent
88d2662664
commit
81bc69fa43
2 changed files with 25 additions and 3 deletions
|
@ -7985,7 +7985,27 @@ function unix.Errno:__tostring() end
|
|||
---@param hostname string for validating that the hostname on the certificate matches what is expected
|
||||
---@return crypto.tls.Connection
|
||||
---@nodiscard
|
||||
function crypto.tls.wrap(fd, hostname)
|
||||
function crypto.tls.wrap(fd, hostname) end
|
||||
|
||||
--- Read data from the TLS connection.
|
||||
---
|
||||
--- This call is blocking.
|
||||
---@param bufsize integer # the maximum amount of data to read from the connection.
|
||||
---@return string # any data read from the connection.
|
||||
function crypto.tls.Connection:read() end
|
||||
|
||||
--- Write data to the TLS connection.
|
||||
---
|
||||
--- This call is blocking.
|
||||
---@param data string # the data to write to the connection.
|
||||
---@return nil
|
||||
function crypto.tls.Connectino:write() end
|
||||
|
||||
--- Close the connection.
|
||||
---
|
||||
--- Also closes the underlying socket.
|
||||
---@return nil
|
||||
function crypto.tls.Connection:close() end
|
||||
-- CONSTANTS
|
||||
|
||||
---@type integer for debug logging level. See `Log`.
|
||||
|
|
|
@ -5159,13 +5159,15 @@ int LuaCryptoTlsConnectionRead(lua_State *L) {
|
|||
lua_Integer bufsiz;
|
||||
bufsiz = luaL_optinteger(L, 2, BUFSIZ);
|
||||
bufsiz = MIN(bufsiz, 0x7ffff00);
|
||||
buf = _gc(malloc(bufsiz));
|
||||
buf = malloc(bufsiz);
|
||||
rc = TlsConnectionRead(GetTlsConnection(L), buf, bufsiz);
|
||||
if (rc != -1) {
|
||||
got = rc;
|
||||
lua_pushlstring(L, buf, got);
|
||||
free(buf);
|
||||
return 1;
|
||||
} else {
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -5229,7 +5231,7 @@ int LuaCryptoTlsWrap(lua_State *L) {
|
|||
} else if (rc == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) {
|
||||
lua_pop(L, 1);
|
||||
return LuaNilTlsError(
|
||||
L, _gc(DescribeSslVerifyFailure(conn->ctx.session_negotiate->verify_result)), rc
|
||||
L, DescribeSslVerifyFailure(conn->ctx.session_negotiate->verify_result), rc
|
||||
);
|
||||
} else {
|
||||
lua_pop(L, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue