Skip to content

Commit

Permalink
Merge pull request h2o#361
Browse files Browse the repository at this point in the history
Conversion fixes for util.h
  • Loading branch information
kazuho committed Dec 13, 2021
2 parents 903f603 + e800b4d commit a966e1b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 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 @@ -124,7 +124,7 @@ static inline void setup_session_file(ptls_context_t *ctx, ptls_handshake_proper
}
}

static inline X509_STORE* init_cert_store(char const *crt_file)
static inline X509_STORE *init_cert_store(char const *crt_file)
{
int ret = 0;
X509_STORE *store = X509_STORE_new();
Expand All @@ -133,8 +133,7 @@ static inline X509_STORE* init_cert_store(char const *crt_file)
X509_LOOKUP *lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
ret = X509_LOOKUP_load_file(lookup, crt_file, X509_FILETYPE_PEM);
if (ret != 1) {
fprintf(stderr, "Cannot load store (%s), ret = %d\n",
crt_file, ret);
fprintf(stderr, "Cannot load store (%s), ret = %d\n", crt_file, ret);
X509_STORE_free(store);
exit(1);
}
Expand Down Expand Up @@ -180,7 +179,8 @@ 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 @@ -337,7 +337,8 @@ static inline ptls_iovec_t resolve_esni_keys(const char *server_name)
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 a966e1b

Please sign in to comment.