uhttpd/file: fix string out of buffer range on uh_defer_script
[project/uhttpd.git] / tls.c
diff --git a/tls.c b/tls.c
index 39b31698e1fe5007400a3878c50a954a15b9053d..1da08812f12e37a9afda89963982f520cfe3be33 100644 (file)
--- a/tls.c
+++ b/tls.c
@@ -31,7 +31,7 @@ static struct ustream_ssl_ops *ops;
 static void *dlh;
 static void *ctx;
 
-int uh_tls_init(const char *key, const char *crt)
+int uh_tls_init(const char *key, const char *crt, const char *ciphers)
 {
        static bool _init = false;
 
@@ -63,19 +63,24 @@ int uh_tls_init(const char *key, const char *crt)
                return -EINVAL;
        }
 
+       if (ciphers && ops->context_set_ciphers(ctx, ciphers)) {
+               fprintf(stderr, "No recognized ciphers in cipher list\n");
+               return -EINVAL;
+       }
+
        return 0;
 }
 
 static void tls_ustream_read_cb(struct ustream *s, int bytes)
 {
-       struct client *cl = container_of(s, struct client, ssl);
+       struct client *cl = container_of(s, struct client, ssl.stream);
 
        uh_client_read_cb(cl);
 }
 
 static void tls_ustream_write_cb(struct ustream *s, int bytes)
 {
-       struct client *cl = container_of(s, struct client, ssl);
+       struct client *cl = container_of(s, struct client, ssl.stream);
 
        if (cl->dispatch.write_cb)
                cl->dispatch.write_cb(cl);
@@ -83,7 +88,7 @@ static void tls_ustream_write_cb(struct ustream *s, int bytes)
 
 static void tls_notify_state(struct ustream *s)
 {
-       struct client *cl = container_of(s, struct client, ssl);
+       struct client *cl = container_of(s, struct client, ssl.stream);
 
        uh_client_notify_state(cl);
 }