diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e8c83808c9b6..067684d4f834a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ in addition to `[skip]`. This allows having custom behavior for different serialization methods. - ORM: fixed a foreign key bug that could result in an extra insert. - Generic functions as function parameters are now supported: `fn f[T](x T, i int, f_ Fn[T]) T { `. -- Enum values now can have attributes. +- Enum values now can have attributes. - json: Enum value string serialization supports `[json:'alias']` to change its string values. +- Functions can now return fixed size arrays. ## V 0.3.4 @@ -142,12 +143,12 @@ Final steps in making the Option type a first class type: a T b U } - + foo := Foo{ a: 2 b: 'x' } - + println(foo) ``` - unsafe: dereferencing nil references is no longer allowed in the following case: diff --git a/vlib/net/mbedtls/ssl_connection.v b/vlib/net/mbedtls/ssl_connection.v index f353216b315da3..d36cccc0f244ff 100644 --- a/vlib/net/mbedtls/ssl_connection.v +++ b/vlib/net/mbedtls/ssl_connection.v @@ -12,14 +12,15 @@ fn init() { $if trace_ssl ? { eprintln(@METHOD) } - C.mbedtls_ctr_drbg_init(&mbedtls.ctr_drbg) - C.mbedtls_entropy_init(&mbedtls.entropy) - - ret := C.mbedtls_ctr_drbg_seed(&mbedtls.ctr_drbg, C.mbedtls_entropy_func, &mbedtls.entropy, - 0, 0) - if ret != 0 { - C.mbedtls_ctr_drbg_free(&mbedtls.ctr_drbg) - panic('Failed to seed ssl context: ${ret}') + unsafe { // Unsafe is needed for taking an address of const + C.mbedtls_ctr_drbg_init(&mbedtls.ctr_drbg) + C.mbedtls_entropy_init(&mbedtls.entropy) + ret := C.mbedtls_ctr_drbg_seed(&mbedtls.ctr_drbg, C.mbedtls_entropy_func, &mbedtls.entropy, + 0, 0) + if ret != 0 { + C.mbedtls_ctr_drbg_free(&mbedtls.ctr_drbg) + panic('Failed to seed ssl context: ${ret}') + } } } @@ -110,7 +111,9 @@ fn (mut s SSLConn) init() ! { return error_with_code('Failed to set SSL configuration', ret) } - C.mbedtls_ssl_conf_rng(&s.conf, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg) + unsafe { + C.mbedtls_ssl_conf_rng(&s.conf, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg) + } if s.config.verify != '' || s.config.cert != '' || s.config.cert_key != '' { s.certs = &SSLCerts{} @@ -127,8 +130,10 @@ fn (mut s SSLConn) init() ! { ret = C.mbedtls_x509_crt_parse(&s.certs.client_cert, s.config.cert.str, s.config.cert.len) } if s.config.cert_key != '' { - ret = C.mbedtls_pk_parse_key(&s.certs.client_key, s.config.cert_key.str, s.config.cert_key.len, - 0, 0, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg) + unsafe { + ret = C.mbedtls_pk_parse_key(&s.certs.client_key, s.config.cert_key.str, + s.config.cert_key.len, 0, 0, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg) + } } } else { if s.config.verify != '' { @@ -138,8 +143,10 @@ fn (mut s SSLConn) init() ! { ret = C.mbedtls_x509_crt_parse_file(&s.certs.client_cert, &char(s.config.cert.str)) } if s.config.cert_key != '' { - ret = C.mbedtls_pk_parse_keyfile(&s.certs.client_key, &char(s.config.cert_key.str), - 0, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg) + unsafe { + ret = C.mbedtls_pk_parse_keyfile(&s.certs.client_key, &char(s.config.cert_key.str), + 0, C.mbedtls_ctr_drbg_random, &mbedtls.ctr_drbg) + } } } if ret < 0 {