summaryrefslogtreecommitdiff
path: root/src/streams/mbedtls.c
Commit message (Collapse)AuthorAgeFilesLines
* mbedtls: fix potential size overflow when reading or writing dataethomson/stream-truncated-writesPatrick Steinhardt2019-01-311-2/+9
| | | | | | | | | | | | | | | | The mbedtls library uses a callback mechanism to allow downstream users to plug in their own receive and send functions. We implement `bio_read` and `bio_write` functions, which simply wrap the `git_stream_read` and `git_stream_write` functions, respectively. The problem arises due to the return value of the callback functions: mbedtls expects us to return an `int` containing the actual number of bytes that were read or written. But this is in fact completely misdesigned, as callers are allowed to pass in a buffer with length `SIZE_MAX`. We thus may be unable to represent the number of bytes written via the return value. Fix this by only ever reading or writing at most `INT_MAX` bytes.
* mbedtls: make global variables staticPatrick Steinhardt2019-01-311-4/+2
| | | | | | The mbedtls stream implementation makes use of some global variables which are not marked as `static`, even though they're only used in this compilation unit. Fix this and remove a duplicate declaration.
* streams: handle short writes only in generic streamPatrick Steinhardt2019-01-311-9/+4
| | | | | | | | Now that the function `git_stream__write_full` exists and callers of `git_stream_write` have been adjusted, we can lift logic for short writes out of the stream implementations. Instead, this is now handled either by `git_stream__write_full` or by callers of `git_stream_write` directly.
* streams: make file-local functions staticPatrick Steinhardt2019-01-311-6/+6
| | | | | | The callback functions that implement the `git_stream` structure are only used inside of their respective implementation files, but they are not marked as `static`. Fix this.
* streams: don't write more than SSIZE_MAXEdward Thomson2019-01-251-6/+6
| | | | | | | | | Our streams implementation takes a `size_t` that indicates the length of the data buffer to be written, and returns an `ssize_t` that indicates the length that _was_ written. Clearly no such implementation can write more than `SSIZE_MAX` bytes. Ensure that each TLS stream implementation does not try to write more than `SSIZE_MAX` bytes (or smaller; if the given implementation takes a smaller size).
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-21/+21
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* http: remove cURLEdward Thomson2018-11-281-11/+1
| | | | | We previously used cURL to support HTTP proxies. Now that we've added this support natively, we can remove the curl dependency.
* streams: remove unused tls functionsEdward Thomson2018-11-281-19/+0
| | | | | | | The implementations of git_openssl_stream_new and git_mbedtls_stream_new have callers protected by #ifdefs and are never called unless compiled in. There's no need for a dummy implementation. Remove them.
* tls: introduce a wrap functionEdward Thomson2018-11-281-13/+50
| | | | | | | | | | | Introduce `git_tls_stream_wrap` which will take an existing `stream` with an already connected socket and begin speaking TLS on top of it. This is useful if you've built a connection to a proxy server and you wish to begin CONNECT over it to tunnel a TLS connection. Also update the pluggable TLS stream layer so that it can accept a registration structure that provides an `init` and `wrap` function, instead of a single initialization function.
* mbedtls: remove unused variable "cacert"Patrick Steinhardt2018-07-261-4/+0
| | | | | | | | | In commit 382ed1e87 (mbedtls: load default CA certificates, 2018-03-29), the function `git_mbedtls_stream_global_init` was refactored to call out to `git_mbedtls__set_cert_location` instead of setting up the certificates itself. The conversion forgot to remove the now-unused "cacert" variable, which is now only getting declared to be free'd at the end of the function. Remove it.
* mbedtls: free stream on shutdownethomson/leaksEdward Thomson2018-07-201-0/+1
|
* mbedtls: make ciphers_list a static arrayEdward Thomson2018-07-201-10/+10
| | | | | Instead of allocating the ciphers_list, make it a static array. This prevents us from leaking it or having to manage its memory.
* mbedtls: free ciphers_listEdward Thomson2018-07-201-0/+2
|
* mbedtls: check allocationsEdward Thomson2018-07-201-1/+14
|
* mbedtls: fix `inline` being used in mbedtls headersPatrick Steinhardt2018-07-131-0/+11
| | | | | | | | | | | | The mbedtls headers make direct use of the `inline` attribute to instruct the compiler to inline functions. As this function is not C90 compliant, this can cause the compiler to error as soon as any of these files is included and the `-std=c90` flag is being added. The mbedtls headers declaring functions as inline always have a prelude which define `inline` as a macro in case it is not yet defined. Thus, we can easily replace their define with our own define, which simply copies the logic of our own `GIT_INLINE` macro.
* mbedtls: display error codes as hex for consistency with mbedTLS docsEtienne Samson2018-04-111-4/+4
| | | | Remaining parts of https://github.com/JuliaLang/julia/blob/8d47a314537779c8fb86642c54925613628a91b0/deps/patches/libgit2-mbedtls-fixup.patch
* mbedtls: load default CA certificatesEtienne Samson2018-04-111-22/+38
|
* mbedtls: use mbedTLS certificate verificationEtienne Samson2018-04-111-69/+6
| | | | Taken from https://github.com/JuliaLang/julia/blob/8d47a314537779c8fb86642c54925613628a91b0/deps/patches/libgit2-mbedtls-verify.patch, with some modifications.
* mbedtls: use our own certificate validationEtienne Samson2018-04-111-1/+5
| | | | | Otherwise REQUIRED means that `git_stream_certificate` will always error. We're doing the mbedtls check in verify_server_cert though.
* mbedtls: fix libgit2 hanging due to incomplete writesEtienne Samson2018-04-111-5/+9
|
* mbedtls: default cipher list supportEtienne Samson2018-04-111-0/+29
|
* mbedtls: add global initializationEtienne Samson2018-04-111-3/+97
|
* mbedtls: proper certificate verificationEtienne Samson2018-04-111-26/+50
|
* mbedtls: initial supportEtienne Samson2018-04-111-0/+344