Skip to content

Commit 0343e64

Browse files
committed
Merge PR 7
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.
1 parent e343725 commit 0343e64

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/tls_cache.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ static rustls_result tls_cache_get(
231231
unsigned int vlen, klen;
232232
const unsigned char *kdata;
233233

234+
if (key->len > UINT_MAX || key->len > SSIZE_MAX) {
235+
return RUSTLS_RESULT_INVALID_PARAMETER;
236+
}
237+
234238
if (!sc->global->session_cache) goto not_found;
235239
tls_cache_lock(sc->global);
236240

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

243247
if (APLOGctrace4(c)) {
244-
apr_ssize_t n = klen;
248+
apr_ssize_t n = (apr_ssize_t) klen;
245249
ap_log_cerror(APLOG_MARK, APLOG_TRACE4, rv, c, "retrieve key %d[%8x], found %d val",
246250
klen, apr_hashfunc_default((const char*)kdata, &n), vlen);
247251
}

0 commit comments

Comments
 (0)