Skip to content

Commit

Permalink
Merge PR 7
Browse files Browse the repository at this point in the history
    tls_cache: fix implicit conversion err on i386/i686

    Previously on arch's where `apr_ssize_t` is an `int` (e.g. i386) the
    `tls_cache_get()` function produced an implicit conversion error of the
    form:

    ```
    error: implicit conversion changes signedness: 'unsigned int' to 'apr_ssize_t' (aka 'int')
    ```

    This commit resolves this error by:

    1. Checking the two casts performed by this function are within the
       range of the types being cast to.
    2. Making the cast to `apr_ssize_t` explicit.
  • Loading branch information
icing committed Feb 6, 2025
1 parent e343725 commit 0343e64
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tls_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ static rustls_result tls_cache_get(
unsigned int vlen, klen;
const unsigned char *kdata;

if (key->len > UINT_MAX || key->len > SSIZE_MAX) {
return RUSTLS_RESULT_INVALID_PARAMETER;
}

if (!sc->global->session_cache) goto not_found;
tls_cache_lock(sc->global);

Expand All @@ -241,7 +245,7 @@ static rustls_result tls_cache_get(
sc->global->session_cache, cc->server, kdata, klen, buf, &vlen, c->pool);

if (APLOGctrace4(c)) {
apr_ssize_t n = klen;
apr_ssize_t n = (apr_ssize_t) klen;
ap_log_cerror(APLOG_MARK, APLOG_TRACE4, rv, c, "retrieve key %d[%8x], found %d val",
klen, apr_hashfunc_default((const char*)kdata, &n), vlen);
}
Expand Down

0 comments on commit 0343e64

Please sign in to comment.