diff --git a/examples/http-client/Makefile b/examples/http-client/Makefile index 66c5e9f6d8bae3289b7bc8ede995915f548a37d7..112c8fff1aed909ed7a5f39e2fe9ac70ff2d1760 100644 --- a/examples/http-client/Makefile +++ b/examples/http-client/Makefile @@ -14,7 +14,7 @@ CFLAGS += -L$(OPENSSL)/lib -lssl -lcrypto endif all: $(PROG) - $(DEBUGGER) ./$(PROG) $(ARGS) + $(RUN) ./$(PROG) $(ARGS) $(PROG): main.c $(CC) ../../mongoose.c -I../.. -W -Wall $(CFLAGS) -o $(PROG) main.c @@ -22,7 +22,7 @@ $(PROG): main.c linux: all linux: CFLAGS += -O2 -g -fsanitize=address,undefined,shift,null,return,bounds,alignment,object-size,bool,enum -static-libasan linux: CC = $(LIN) cc -linux: DEBUGGER = $(LIN) +linux: RUN = $(LIN) clean: rm -rf $(PROG) *.o *.dSYM *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb diff --git a/mongoose.c b/mongoose.c index ee990d01d8cef3208b49072e650215bc284d8b46..bc26f1dc0683eecb5f124fba3a203b64a3195c16 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3725,13 +3725,15 @@ static int rng_get(void *p_rng, unsigned char *buf, size_t len) { void mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) { struct mg_tls *tls = (struct mg_tls *) calloc(1, sizeof(*tls)); int rc = 0; - const char *ca = - opts->ca == NULL ? "-" : opts->ca[0] == '-' ? "(emb)" : opts->ca; - const char *cert = - opts->cert == NULL ? "-" : opts->cert[0] == '-' ? "(emb)" : opts->cert; - const char *certkey = opts->certkey == NULL - ? "-" - : opts->certkey[0] == '-' ? "(emb)" : opts->certkey; + const char *ca = opts->ca == NULL ? "-" + : opts->ca[0] == '-' ? "(emb)" + : opts->ca; + const char *cert = opts->cert == NULL ? "-" + : opts->cert[0] == '-' ? "(emb)" + : opts->cert; + const char *certkey = opts->certkey == NULL ? "-" + : opts->certkey[0] == '-' ? "(emb)" + : opts->certkey; if (tls == NULL) { mg_error(c, "TLS OOM"); goto fail; @@ -3979,9 +3981,8 @@ void mg_tls_handshake(struct mg_connection *c) { LOG(LL_DEBUG, ("%lu success", c->id)); c->is_tls_hs = 0; } else { - int code; + int code = mg_tls_err(tls, rc); ERR_print_errors_fp(stderr); - code = mg_tls_err(tls, rc); if (code != 0) mg_error(c, "tls hs: rc %d, err %d", rc, code); } } diff --git a/src/tls.c b/src/tls.c index 0066c8d6b8b78e7aa9b659153f93a6eafd17e142..d75bcadc4749853a3582b54aa01716458407f95d 100644 --- a/src/tls.c +++ b/src/tls.c @@ -77,13 +77,15 @@ static int rng_get(void *p_rng, unsigned char *buf, size_t len) { void mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) { struct mg_tls *tls = (struct mg_tls *) calloc(1, sizeof(*tls)); int rc = 0; - const char *ca = - opts->ca == NULL ? "-" : opts->ca[0] == '-' ? "(emb)" : opts->ca; - const char *cert = - opts->cert == NULL ? "-" : opts->cert[0] == '-' ? "(emb)" : opts->cert; - const char *certkey = opts->certkey == NULL - ? "-" - : opts->certkey[0] == '-' ? "(emb)" : opts->certkey; + const char *ca = opts->ca == NULL ? "-" + : opts->ca[0] == '-' ? "(emb)" + : opts->ca; + const char *cert = opts->cert == NULL ? "-" + : opts->cert[0] == '-' ? "(emb)" + : opts->cert; + const char *certkey = opts->certkey == NULL ? "-" + : opts->certkey[0] == '-' ? "(emb)" + : opts->certkey; if (tls == NULL) { mg_error(c, "TLS OOM"); goto fail; @@ -331,9 +333,8 @@ void mg_tls_handshake(struct mg_connection *c) { LOG(LL_DEBUG, ("%lu success", c->id)); c->is_tls_hs = 0; } else { - int code; + int code = mg_tls_err(tls, rc); ERR_print_errors_fp(stderr); - code = mg_tls_err(tls, rc); if (code != 0) mg_error(c, "tls hs: rc %d, err %d", rc, code); } }