diff --git a/.gitignore b/.gitignore
index 3248d45..b58d2dd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,10 @@ build_lib_asan
build_lib_cov
build_lib_debug
build_lib_main
+build_objc_asan
+build_objc_cov
+build_objc_debug
+build_objc_main
build_prog_asan
build_prog_cov
build_prog_debug
diff --git a/lib/kc3/0.1/crypt.kc3 b/lib/kc3/0.1/crypt.kc3
index 6ead892..adfbe27 100644
--- a/lib/kc3/0.1/crypt.kc3
+++ b/lib/kc3/0.1/crypt.kc3
@@ -13,7 +13,7 @@ defmodule Crypt do
def sha512_hash_password = fn (password) {
salt = Str.random_base64(16)
- sha512(password, "$6$rounds=123456$#{salt}$")
+ sha512(password, "$6$rounds=1234567$#{salt}$")
}
end
diff --git a/libkc3/cfn.c b/libkc3/cfn.c
index b404473..007b63c 100644
--- a/libkc3/cfn.c
+++ b/libkc3/cfn.c
@@ -50,7 +50,7 @@ s_tag * cfn_apply (s_cfn *cfn, s_list *args, s_tag *dest)
err_write_1(": invalid number of arguments, expected ");
err_inspect_u8(&arity);
err_write_1(", have ");
- err_inspect_sw(&num_args);
+ err_inspect_sw_decimal(&num_args);
err_write_1("\n");
return NULL;
}
diff --git a/libkc3/crypt.c b/libkc3/crypt.c
index e1bf741..b54de37 100644
--- a/libkc3/crypt.c
+++ b/libkc3/crypt.c
@@ -23,7 +23,7 @@
#include "str.h"
#include "tag.h"
-#if HAVE_CRYPT_NEWHASH
+#if HAVE_CRYPT_NEWHASH && 0
bool * crypt_check_password (const s_str *pass, const s_str *hash,
bool *dest)
diff --git a/libkc3/crypt_sha512.c b/libkc3/crypt_sha512.c
index 21ba45f..61f0a58 100644
--- a/libkc3/crypt_sha512.c
+++ b/libkc3/crypt_sha512.c
@@ -37,7 +37,7 @@ typedef struct sha512 {
#define SALT_MAX 16
#define ROUNDS_DEFAULT 12345
#define ROUNDS_MIN 1000
-#define ROUNDS_MAX 9999999
+#define ROUNDS_MAX 999999999
static const u8 b64[] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -290,7 +290,7 @@ static char * sha512_crypt(const char *key, const char *setting, char *output)
* including non-portable hashes that depend on
* the host's value of ULONG_MAX.
*/
- salt += sizeof "rounds=" - 1;
+ salt += sizeof("rounds=") - 1;
if (! isdigit(*salt))
return 0;
u = strtoul(salt, &end, 10);
diff --git a/libkc3/env.c b/libkc3/env.c
index dcdc0a4..4c3dd29 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -1397,12 +1397,7 @@ bool env_eval_equal_tuple (s_env *env, bool macro, s_tuple *a,
assert(b);
assert(dest);
if (a->count != b->count) {
- err_write_1("env_eval_equal_tuple: tuple arity mismatch between"
- "\n ");
- err_inspect_tuple(a);
- err_write_1("\nand\n ");
- err_inspect_tuple(b);
- err_write_1("\n");
+ err_puts("env_eval_equal_tuple: tuple arity mismatch");
assert(! "env_eval_equal_tuple: tuple arity mismatch");
return false;
}
@@ -1411,11 +1406,8 @@ bool env_eval_equal_tuple (s_env *env, bool macro, s_tuple *a,
while (i < a->count) {
if (! env_eval_equal_tag(env, macro, a->tag + i, b->tag + i,
tmp.tag + i)) {
- err_write_1("env_eval_equal_tuple: tuple tag mismatch between"
- "\n ");
- err_inspect_tuple(a);
- err_write_1("\nand\n ");
- err_inspect_tuple(b);
+ err_write_1("env_eval_equal_tuple: tuple tag mismatch index ");
+ err_inspect_uw(&i);
err_write_1("\n");
assert(! "env_eval_equal_tuple: tuple tag mismatch");
tuple_clean(&tmp);
diff --git a/libkc3/str.c b/libkc3/str.c
index 2aba3df..c1ad53d 100644
--- a/libkc3/str.c
+++ b/libkc3/str.c
@@ -36,6 +36,7 @@
#include "list.h"
#include "operator.h"
#include "str.h"
+#include "sw.h"
#include "sym.h"
#include "tag.h"
#include "tag_type.h"
@@ -790,21 +791,30 @@ s_str * str_init_random_base64 (s_str *str, const s_tag *len)
{
const s_sym *type;
char *random_bytes;
- uw random_bytes_len;
+ sw random_bytes_len;
char *result;
- uw result_len;
+ sw result_len;
uw i;
uw j;
uw k;
uw u;
type = &g_sym_Uw;
- if (! uw_init_cast(&result_len, &type, len)) {
+ if (! sw_init_cast(&result_len, &type, len)) {
err_write_1("str_init_random_base64: cannot cast to Uw: ");
err_inspect_tag(len);
err_write_1("\n");
return NULL;
}
- random_bytes_len = ceil(log2(pow(64, result_len)) / 8);
+ if (result_len < 0)
+ return NULL;
+ random_bytes_len = result_len / 3;
+ if (random_bytes_len <= 0)
+ return NULL;
+ if (true) {
+ err_write_1("str_init_random_base64: random_bytes_len: ");
+ err_inspect_sw_decimal(&random_bytes_len);
+ err_write_1("\n");
+ }
if (! (random_bytes = alloc(random_bytes_len)))
return NULL;
if (! (result = alloc(result_len + 1))) {
@@ -814,14 +824,14 @@ s_str * str_init_random_base64 (s_str *str, const s_tag *len)
arc4random_buf(random_bytes, random_bytes_len);
i = 0;
j = 0;
- while (i + 3 <= random_bytes_len &&
- j < result_len) {
+ while (i + 3 <= (uw) random_bytes_len &&
+ j < (uw) result_len) {
u = ((random_bytes[i] << 16) +
(random_bytes[i + 1] << 8) +
(random_bytes[i + 2]));
k = 0;
while (k < 4 &&
- j < result_len) {
+ j < (uw) result_len) {
result[j] = g_kc3_base64url.ptr.pchar[u % 64];
u /= 64;
j++;
@@ -833,7 +843,7 @@ s_str * str_init_random_base64 (s_str *str, const s_tag *len)
u = ((random_bytes[i] << 8) +
random_bytes[i + 1]);
k = 0;
- while (j < result_len) {
+ while (j < (uw) result_len) {
result[j] = g_kc3_base64url.ptr.pchar[u % 64];
u /= 64;
j++;
@@ -843,7 +853,7 @@ s_str * str_init_random_base64 (s_str *str, const s_tag *len)
else if (random_bytes_len - i == 1) {
u = random_bytes[i];
k = 0;
- while (j < result_len) {
+ while (j < (uw) result_len) {
result[j] = g_kc3_base64url.ptr.pchar[u % 64];
u /= 64;
j++;
diff --git a/smtp b/smtp
index 1caff75..9288123 160000
--- a/smtp
+++ b/smtp
@@ -1 +1 @@
-Subproject commit 1caff75f7b79ac30fc125e44583d2cfd102936fb
+Subproject commit 92881231b2e3434fec66028ad6d70a52ff5b0135