summaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-12-05 16:24:46 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-12-05 16:24:46 +0000
commitb4d6ebf474c8f4257cbe50ae1663ea58ab3b08c1 (patch)
tree79f912b49cfdf947aab650f1c2450f4483bb1d3f /src/libutil
parent15d023291bedb5cbd2634c05f79185ab6a358c6c (diff)
downloadrspamd-b4d6ebf474c8f4257cbe50ae1663ea58ab3b08c1.tar.gz
rspamd-b4d6ebf474c8f4257cbe50ae1663ea58ab3b08c1.zip
[Project] Move the whole backend to C++
Easier to work further.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/cxx/file_util.cxx8
-rw-r--r--src/libutil/util.c4
-rw-r--r--src/libutil/util.h2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/libutil/cxx/file_util.cxx b/src/libutil/cxx/file_util.cxx
index 9baf062a5..2f031f076 100644
--- a/src/libutil/cxx/file_util.cxx
+++ b/src/libutil/cxx/file_util.cxx
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2022 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -319,7 +319,7 @@ auto random_fname(std::string_view extension)
std::string out_fname{tmpdir};
out_fname += G_DIR_SEPARATOR_S;
- unsigned char hexbuf[32];
+ char hexbuf[32];
rspamd_random_hex(hexbuf, sizeof(hexbuf));
out_fname.append((const char *) hexbuf, sizeof(hexbuf));
if (!extension.empty()) {
diff --git a/src/libutil/util.c b/src/libutil/util.c
index aa89e84c8..31bb86200 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1586,14 +1586,14 @@ rspamd_get_calendar_ticks(void)
return res;
}
-void rspamd_random_hex(guchar *buf, guint64 len)
+void rspamd_random_hex(gchar *buf, guint64 len)
{
static const gchar hexdigests[16] = "0123456789abcdef";
gint64 i;
g_assert(len > 0);
- ottery_rand_bytes(buf, ceil(len / 2.0));
+ ottery_rand_bytes((void *) buf, ceil(len / 2.0));
for (i = (gint64) len - 1; i >= 0; i -= 2) {
buf[i] = hexdigests[buf[i / 2] & 0xf];
diff --git a/src/libutil/util.h b/src/libutil/util.h
index 17956acb7..aecd1b048 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -377,7 +377,7 @@ guint64 rspamd_hash_seed(void);
* @param buf
* @param len
*/
-void rspamd_random_hex(guchar *buf, guint64 len);
+void rspamd_random_hex(gchar *buf, guint64 len);
/**
* Returns