Skip to content

Commit

Permalink
Conversion fixes for utils.h
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Jun 4, 2021
1 parent ea3e079 commit 457a457
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions t/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct st_util_save_ticket_t {

static int util_save_ticket_cb(ptls_save_ticket_t *_self, ptls_t *tls, ptls_iovec_t src)
{
struct st_util_save_ticket_t *self = (void *)_self;
struct st_util_save_ticket_t *self = (struct st_util_save_ticket_t*)_self;
FILE *fp;

if ((fp = fopen(self->fn, "wb")) == NULL) {
Expand Down Expand Up @@ -180,7 +180,7 @@ static inline void setup_esni(ptls_context_t *ctx, const char *esni_fn, ptls_key
fclose(fp);
}

if ((ctx->esni = malloc(sizeof(*ctx->esni) * 2)) == NULL || (*ctx->esni = malloc(sizeof(**ctx->esni))) == NULL) {
if ((ctx->esni = (ptls_esni_context_t**) malloc(sizeof(*ctx->esni) * 2)) == NULL || (*ctx->esni = (ptls_esni_context_t*) malloc(sizeof(**ctx->esni))) == NULL) {
fprintf(stderr, "no memory\n");
exit(1);
}
Expand All @@ -198,7 +198,7 @@ struct st_util_log_event_t {

static void log_event_cb(ptls_log_event_t *_self, ptls_t *tls, const char *type, const char *fmt, ...)
{
struct st_util_log_event_t *self = (void *)_self;
struct st_util_log_event_t *self = (struct st_util_log_event_t*)_self;
char randomhex[PTLS_HELLO_RANDOM_SIZE * 2 + 1];
va_list args;

Expand Down Expand Up @@ -234,14 +234,14 @@ struct st_util_session_cache_t {

static int encrypt_ticket_cb(ptls_encrypt_ticket_t *_self, ptls_t *tls, int is_encrypt, ptls_buffer_t *dst, ptls_iovec_t src)
{
struct st_util_session_cache_t *self = (void *)_self;
struct st_util_session_cache_t *self = (struct st_util_session_cache_t*)_self;
int ret;

if (is_encrypt) {

/* replace the cached entry along with a newly generated session id */
free(self->data.base);
if ((self->data.base = malloc(src.len)) == NULL)
if ((self->data.base = (uint8_t *) malloc(src.len)) == NULL)
return PTLS_ERROR_NO_MEMORY;

ptls_get_context(tls)->random_bytes(self->id, sizeof(self->id));
Expand Down Expand Up @@ -336,8 +336,9 @@ static inline ptls_iovec_t resolve_esni_keys(const char *server_name)
ptls_buffer_t decode_buf;
ptls_base64_decode_state_t ds;
int answer_len;

ptls_buffer_init(&decode_buf, "", 0);

char* buf = "";
ptls_buffer_init(&decode_buf, buf, 0);

if (snprintf(esni_name, sizeof(esni_name), "_esni.%s", server_name) > sizeof(esni_name) - 1)
goto Error;
Expand All @@ -349,8 +350,8 @@ static inline ptls_iovec_t resolve_esni_keys(const char *server_name)
goto Error;
if (ns_parserr(&msg, ns_s_an, 0, &rr) != 0)
goto Error;
base64 = (void *)ns_rr_rdata(rr);
if (!normalize_txt((void *)base64, ns_rr_rdlen(rr)))
base64 = (char *)ns_rr_rdata(rr);
if (!normalize_txt((uint8_t *)base64, ns_rr_rdlen(rr)))
goto Error;

ptls_base64_decode_init(&ds);
Expand Down

0 comments on commit 457a457

Please sign in to comment.