diff options
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/archives.c | 112 | ||||
-rw-r--r-- | src/libmime/content_type.c | 8 | ||||
-rw-r--r-- | src/libmime/images.c | 20 | ||||
-rw-r--r-- | src/libmime/images.h | 4 | ||||
-rw-r--r-- | src/libmime/lang_detection.c | 10 | ||||
-rw-r--r-- | src/libmime/message.c | 22 | ||||
-rw-r--r-- | src/libmime/message.h | 2 | ||||
-rw-r--r-- | src/libmime/mime_encoding.c | 16 | ||||
-rw-r--r-- | src/libmime/mime_encoding.h | 12 | ||||
-rw-r--r-- | src/libmime/mime_expressions.c | 4 | ||||
-rw-r--r-- | src/libmime/mime_headers.c | 10 | ||||
-rw-r--r-- | src/libmime/mime_parser.c | 8 | ||||
-rw-r--r-- | src/libmime/smtp_parsers.h | 2 |
13 files changed, 115 insertions, 115 deletions
diff --git a/src/libmime/archives.c b/src/libmime/archives.c index 23966484e..7f77cf591 100644 --- a/src/libmime/archives.c +++ b/src/libmime/archives.c @@ -68,7 +68,7 @@ rspamd_archive_file_try_utf(struct rspamd_task *task, if (charset) { UChar *tmp; UErrorCode uc_err = U_ZERO_ERROR; - gint32 r, clen, dlen; + int32_t r, clen, dlen; struct rspamd_charset_converter *conv; UConverter *utf8_converter; @@ -174,10 +174,10 @@ rspamd_archive_process_zip(struct rspamd_task *task, struct rspamd_mime_part *part) { const guchar *p, *start, *end, *eocd = NULL, *cd; - const guint32 eocd_magic = 0x06054b50, cd_basic_len = 46; + const uint32_t eocd_magic = 0x06054b50, cd_basic_len = 46; const guchar cd_magic[] = {0x50, 0x4b, 0x01, 0x02}; const guint max_processed = 1024; - guint32 cd_offset, cd_size, comp_size, uncomp_size, processed = 0; + uint32_t cd_offset, cd_size, comp_size, uncomp_size, processed = 0; guint16 extra_len, fname_len, comment_len; struct rspamd_archive *arch; struct rspamd_archive_file *f = NULL; @@ -193,8 +193,8 @@ rspamd_archive_process_zip(struct rspamd_task *task, */ p -= 21; - while (p > start + sizeof(guint32)) { - guint32 t; + while (p > start + sizeof(uint32_t)) { + uint32_t t; if (processed > max_processed) { break; @@ -263,9 +263,9 @@ rspamd_archive_process_zip(struct rspamd_task *task, memcpy(&flags, cd + 8, sizeof(guint16)); flags = GUINT16_FROM_LE(flags); - memcpy(&comp_size, cd + 20, sizeof(guint32)); + memcpy(&comp_size, cd + 20, sizeof(uint32_t)); comp_size = GUINT32_FROM_LE(comp_size); - memcpy(&uncomp_size, cd + 24, sizeof(guint32)); + memcpy(&uncomp_size, cd + 24, sizeof(uint32_t)); uncomp_size = GUINT32_FROM_LE(uncomp_size); memcpy(&fname_len, cd + 28, sizeof(fname_len)); fname_len = GUINT16_FROM_LE(fname_len); @@ -333,7 +333,7 @@ rspamd_archive_process_zip(struct rspamd_task *task, } static inline gint -rspamd_archive_rar_read_vint(const guchar *start, gsize remain, guint64 *res) +rspamd_archive_rar_read_vint(const guchar *start, gsize remain, uint64_t *res) { /* * From http://www.rarlab.com/technote.htm: @@ -344,16 +344,16 @@ rspamd_archive_rar_read_vint(const guchar *start, gsize remain, guint64 *res) * So first byte contains 7 least significant bits of integer and * continuation flag. Second byte, if present, contains next 7 bits and so on. */ - guint64 t = 0; + uint64_t t = 0; guint shift = 0; const guchar *p = start; while (remain > 0 && shift <= 57) { if (*p & 0x80) { - t |= ((guint64) (*p & 0x7f)) << shift; + t |= ((uint64_t) (*p & 0x7f)) << shift; } else { - t |= ((guint64) (*p & 0x7f)) << shift; + t |= ((uint64_t) (*p & 0x7f)) << shift; p++; break; } @@ -420,12 +420,12 @@ rspamd_archive_rar_read_vint(const guchar *start, gsize remain, guint64 *res) #define RAR_READ_UINT32(n) \ do { \ - if (end - p < (glong) sizeof(guint32)) { \ + if (end - p < (glong) sizeof(uint32_t)) { \ msg_debug_archive("rar archive is invalid (bad int32)"); \ return; \ } \ n = (guint) p[0] + ((guint) p[1] << 8) + ((guint) p[2] << 16) + ((guint) p[3] << 24); \ - p += sizeof(guint32); \ + p += sizeof(uint32_t); \ } while (0) static void @@ -435,7 +435,7 @@ rspamd_archive_process_rar_v4(struct rspamd_task *task, const guchar *start, const guchar *p = start, *start_section; guint8 type; guint flags; - guint64 sz, comp_sz = 0, uncomp_sz = 0; + uint64_t sz, comp_sz = 0, uncomp_sz = 0; struct rspamd_archive *arch; struct rspamd_archive_file *f; @@ -468,7 +468,7 @@ rspamd_archive_process_rar_v4(struct rspamd_task *task, const guchar *start, if (flags & 0x8000) { /* We also need to read ADD_SIZE element */ - guint32 tmp; + uint32_t tmp; RAR_READ_UINT32(tmp); sz += tmp; @@ -505,7 +505,7 @@ rspamd_archive_process_rar_v4(struct rspamd_task *task, const guchar *start, if (flags & 0x100) { /* We also need to read HIGH_PACK_SIZE */ - guint32 tmp; + uint32_t tmp; RAR_READ_UINT32(tmp); sz += tmp; @@ -579,8 +579,8 @@ rspamd_archive_process_rar(struct rspamd_task *task, rar_v4_magic[] = {0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00}; const guint rar_encrypted_header = 4, rar_main_header = 1, rar_file_header = 2; - guint64 vint, sz, comp_sz = 0, uncomp_sz = 0, flags = 0, type = 0, - extra_sz = 0; + uint64_t vint, sz, comp_sz = 0, uncomp_sz = 0, flags = 0, type = 0, + extra_sz = 0; struct rspamd_archive *arch; struct rspamd_archive_file *f; gint r; @@ -621,7 +621,7 @@ rspamd_archive_process_rar(struct rspamd_task *task, /* Now we can have either encryption header or archive header */ /* Crc 32 */ - RAR_SKIP_BYTES(sizeof(guint32)); + RAR_SKIP_BYTES(sizeof(uint32_t)); /* Size */ RAR_READ_VINT_SKIP(); sz = vint; @@ -662,7 +662,7 @@ rspamd_archive_process_rar(struct rspamd_task *task, gboolean has_extra = FALSE; /* Read the next header */ /* Crc 32 */ - RAR_SKIP_BYTES(sizeof(guint32)); + RAR_SKIP_BYTES(sizeof(uint32_t)); /* Size */ RAR_READ_VINT_SKIP(); @@ -702,7 +702,7 @@ rspamd_archive_process_rar(struct rspamd_task *task, } else { /* We have a file header, go forward */ - guint64 fname_len; + uint64_t fname_len; bool is_directory = false; /* File header specific flags */ @@ -717,11 +717,11 @@ rspamd_archive_process_rar(struct rspamd_task *task, if (flags & 0x2) { /* Unix mtime */ - RAR_SKIP_BYTES(sizeof(guint32)); + RAR_SKIP_BYTES(sizeof(uint32_t)); } if (flags & 0x4) { /* Crc32 */ - RAR_SKIP_BYTES(sizeof(guint32)); + RAR_SKIP_BYTES(sizeof(uint32_t)); } if (flags & 0x1) { /* Ignore directories for sanity purposes */ @@ -768,7 +768,7 @@ rspamd_archive_process_rar(struct rspamd_task *task, while (ex < p + extra_sz) { const guchar *t; - gint64 cur_sz = 0, sec_type = 0; + int64_t cur_sz = 0, sec_type = 0; r = rspamd_archive_rar_read_vint(ex, extra_sz, &cur_sz); if (r == -1) { @@ -808,7 +808,7 @@ end: } static inline gint -rspamd_archive_7zip_read_vint(const guchar *start, gsize remain, guint64 *res) +rspamd_archive_7zip_read_vint(const guchar *start, gsize remain, uint64_t *res) { /* * REAL_UINT64 means real UINT64. @@ -839,17 +839,17 @@ rspamd_archive_7zip_read_vint(const guchar *start, gsize remain, guint64 *res) return 1; } else if (t == 0xFF) { - if (remain >= sizeof(guint64) + 1) { - memcpy(res, start + 1, sizeof(guint64)); + if (remain >= sizeof(uint64_t) + 1) { + memcpy(res, start + 1, sizeof(uint64_t)); *res = GUINT64_FROM_LE(*res); - return sizeof(guint64) + 1; + return sizeof(uint64_t) + 1; } } else { gint cur_bit = 6, intlen = 1; const guchar bmask = 0xFF; - guint64 tgt; + uint64_t tgt; while (cur_bit > 0) { if (!isset(&t, cur_bit)) { @@ -859,7 +859,7 @@ rspamd_archive_7zip_read_vint(const guchar *start, gsize remain, guint64 *res) /* Shift back */ tgt >>= sizeof(tgt) - NBBY * intlen; /* Add masked value */ - tgt += (guint64) (t & (bmask >> (NBBY - cur_bit))) + tgt += (uint64_t) (t & (bmask >> (NBBY - cur_bit))) << (NBBY * intlen); *res = tgt; @@ -896,13 +896,13 @@ rspamd_archive_7zip_read_vint(const guchar *start, gsize remain, guint64 *res) #define SZ_READ_UINT64(n) \ do { \ - if (end - p < (goffset) sizeof(guint64)) { \ + if (end - p < (goffset) sizeof(uint64_t)) { \ msg_debug_archive("7zip archive is invalid (bad uint64): %s", G_STRLOC); \ return; \ } \ - memcpy(&(n), p, sizeof(guint64)); \ + memcpy(&(n), p, sizeof(uint64_t)); \ n = GUINT64_FROM_LE(n); \ - p += sizeof(guint64); \ + p += sizeof(uint64_t); \ } while (0) #define SZ_SKIP_BYTES(n) \ do { \ @@ -985,11 +985,11 @@ static const guchar * rspamd_7zip_read_digest(struct rspamd_task *task, const guchar *p, const guchar *end, struct rspamd_archive *arch, - guint64 num_streams, + uint64_t num_streams, guint *pdigest_read) { guchar all_defined = *p; - guint64 i; + uint64_t i; guint num_defined = 0; /* * BYTE AllAreDefined @@ -1019,7 +1019,7 @@ rspamd_7zip_read_digest(struct rspamd_task *task, } for (i = 0; i < num_defined; i++) { - SZ_SKIP_BYTES(sizeof(guint32)); + SZ_SKIP_BYTES(sizeof(uint32_t)); } if (pdigest_read) { @@ -1034,7 +1034,7 @@ rspamd_7zip_read_pack_info(struct rspamd_task *task, const guchar *p, const guchar *end, struct rspamd_archive *arch) { - guint64 pack_pos = 0, pack_streams = 0, i, cur_sz; + uint64_t pack_pos = 0, pack_streams = 0, i, cur_sz; guint num_digests = 0; guchar t; /* @@ -1094,12 +1094,12 @@ rspamd_7zip_read_folder(struct rspamd_task *task, const guchar *p, const guchar *end, struct rspamd_archive *arch, guint *pnstreams, guint *ndigests) { - guint64 ncoders = 0, i, j, noutstreams = 0, ninstreams = 0; + uint64_t ncoders = 0, i, j, noutstreams = 0, ninstreams = 0; SZ_READ_VINT(ncoders); for (i = 0; i < ncoders && p != NULL && p < end; i++) { - guint64 sz, tmp; + uint64_t sz, tmp; guchar t; /* * BYTE @@ -1163,21 +1163,21 @@ rspamd_7zip_read_folder(struct rspamd_task *task, if (noutstreams > 1) { /* BindPairs, WTF, huh */ for (i = 0; i < noutstreams - 1; i++) { - guint64 tmp; + uint64_t tmp; SZ_READ_VINT(tmp); SZ_READ_VINT(tmp); } } - gint64 npacked = (gint64) ninstreams - (gint64) noutstreams + 1; + int64_t npacked = (int64_t) ninstreams - (int64_t) noutstreams + 1; msg_debug_archive("7zip: instreams=%L, outstreams=%L, packed=%L", ninstreams, noutstreams, npacked); if (npacked > 1) { /* Gah... */ for (i = 0; i < npacked; i++) { - guint64 tmp; + uint64_t tmp; SZ_READ_VINT(tmp); } @@ -1195,7 +1195,7 @@ rspamd_7zip_read_coders_info(struct rspamd_task *task, struct rspamd_archive *arch, guint *pnum_folders, guint *pnum_nodigest) { - guint64 num_folders = 0, i, tmp; + uint64_t num_folders = 0, i, tmp; guchar t; guint *folder_nstreams = NULL, num_digests = 0, digests_read = 0; @@ -1323,15 +1323,15 @@ rspamd_7zip_read_substreams_info(struct rspamd_task *task, { guchar t; guint i; - guint64 *folder_nstreams; + uint64_t *folder_nstreams; if (num_folders > 8192) { /* Gah */ return NULL; } - folder_nstreams = g_alloca(sizeof(guint64) * num_folders); - memset(folder_nstreams, 0, sizeof(guint64) * num_folders); + folder_nstreams = g_alloca(sizeof(uint64_t) * num_folders); + memset(folder_nstreams, 0, sizeof(uint64_t) * num_folders); while (p != NULL && p < end) { /* @@ -1360,7 +1360,7 @@ rspamd_7zip_read_substreams_info(struct rspamd_task *task, switch (t) { case kNumUnPackStream: for (i = 0; i < num_folders; i++) { - guint64 tmp; + uint64_t tmp; SZ_READ_VINT(tmp); folder_nstreams[i] = tmp; @@ -1381,7 +1381,7 @@ rspamd_7zip_read_substreams_info(struct rspamd_task *task, */ for (i = 0; i < num_folders; i++) { for (guint j = 0; j < folder_nstreams[i]; j++) { - guint64 tmp; + uint64_t tmp; SZ_READ_VINT(tmp); /* Who cares indeed */ } @@ -1465,7 +1465,7 @@ rspamd_7zip_read_archive_props(struct rspamd_task *task, struct rspamd_archive *arch) { guchar proptype; - guint64 proplen; + uint64_t proplen; /* * for (;;) @@ -1543,7 +1543,7 @@ rspamd_7zip_read_files_info(struct rspamd_task *task, const guchar *p, const guchar *end, struct rspamd_archive *arch) { - guint64 nfiles = 0, sz, i; + uint64_t nfiles = 0, sz, i; guchar t, b; struct rspamd_archive_file *fentry; @@ -1584,7 +1584,7 @@ rspamd_7zip_read_files_info(struct rspamd_task *task, /* TODO: for the god sake, do something about external * filenames... */ - guint64 tmp; + uint64_t tmp; SZ_READ_VINT(tmp); } @@ -1734,13 +1734,13 @@ rspamd_archive_process_7zip(struct rspamd_task *task, struct rspamd_archive *arch; const guchar *start, *p, *end; const guchar sz_magic[] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; - guint64 section_offset = 0, section_length = 0; + uint64_t section_offset = 0, section_length = 0; start = part->parsed_data.begin; p = start; end = p + part->parsed_data.len; - if (end - p <= sizeof(guint64) + sizeof(guint32) || + if (end - p <= sizeof(uint64_t) + sizeof(uint32_t) || memcmp(p, sz_magic, sizeof(sz_magic)) != 0) { msg_debug_archive("7z archive is invalid (no 7z magic)"); @@ -1754,13 +1754,13 @@ rspamd_archive_process_7zip(struct rspamd_task *task, arch); /* Magic (6 bytes) + version (2 bytes) + crc32 (4 bytes) */ - p += sizeof(guint64) + sizeof(guint32); + p += sizeof(uint64_t) + sizeof(uint32_t); SZ_READ_UINT64(section_offset); SZ_READ_UINT64(section_length); - if (end - p > sizeof(guint32)) { - p += sizeof(guint32); + if (end - p > sizeof(uint32_t)) { + p += sizeof(uint32_t); } else { msg_debug_archive("7z archive is invalid (truncated crc)"); diff --git a/src/libmime/content_type.c b/src/libmime/content_type.c index 765cb8799..1b5c77987 100644 --- a/src/libmime/content_type.c +++ b/src/libmime/content_type.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 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, @@ -163,7 +163,7 @@ rspamd_param_maybe_rfc2231_process(rspamd_mempool_t *pool, return TRUE; } -static gint32 +static int32_t rspamd_cmp_pieces(struct rspamd_content_type_param *p1, struct rspamd_content_type_param *p2) { return p1->rfc2231_id - p2->rfc2231_id; diff --git a/src/libmime/images.c b/src/libmime/images.c index 1344d913f..be4d02f06 100644 --- a/src/libmime/images.c +++ b/src/libmime/images.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 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, @@ -107,7 +107,7 @@ static struct rspamd_image * process_png_image(rspamd_mempool_t *pool, rspamd_ftok_t *data) { struct rspamd_image *img; - guint32 t; + uint32_t t; const guint8 *p; if (data->len < 24) { @@ -128,10 +128,10 @@ process_png_image(rspamd_mempool_t *pool, rspamd_ftok_t *data) img->data = data; p += 4; - memcpy(&t, p, sizeof(guint32)); + memcpy(&t, p, sizeof(uint32_t)); img->width = ntohl(t); p += 4; - memcpy(&t, p, sizeof(guint32)); + memcpy(&t, p, sizeof(uint32_t)); img->height = ntohl(t); return img; @@ -209,7 +209,7 @@ static struct rspamd_image * process_bmp_image(rspamd_mempool_t *pool, rspamd_ftok_t *data) { struct rspamd_image *img; - gint32 t; + int32_t t; const guint8 *p; if (data->len < 28) { @@ -221,9 +221,9 @@ process_bmp_image(rspamd_mempool_t *pool, rspamd_ftok_t *data) img->type = IMAGE_TYPE_BMP; img->data = data; p = data->begin + 18; - memcpy(&t, p, sizeof(guint32)); + memcpy(&t, p, sizeof(uint32_t)); img->width = GUINT32_FROM_LE(t); - memcpy(&t, p + 4, sizeof(gint32)); + memcpy(&t, p + 4, sizeof(int32_t)); img->height = GUINT32_FROM_LE(t); return img; @@ -373,7 +373,7 @@ rspamd_image_cache_entry_dtor(gpointer p) g_free(entry); } -static guint32 +static uint32_t rspamd_image_dct_hash(gconstpointer p) { return rspamd_cryptobox_fast_hash(p, rspamd_cryptobox_HASHBYTES, diff --git a/src/libmime/images.h b/src/libmime/images.h index bf8b3be39..a70fb7eab 100644 --- a/src/libmime/images.h +++ b/src/libmime/images.h @@ -28,8 +28,8 @@ struct rspamd_image { rspamd_ftok_t *filename; struct html_image *html_image; enum rspamd_image_type type; - guint32 width; - guint32 height; + uint32_t width; + uint32_t height; gboolean is_normalized; guchar *dct; }; diff --git a/src/libmime/lang_detection.c b/src/libmime/lang_detection.c index c485de5ad..0321ee7df 100644 --- a/src/libmime/lang_detection.c +++ b/src/libmime/lang_detection.c @@ -938,10 +938,10 @@ end: static void rspamd_language_detector_random_select(GArray *ucs_tokens, guint nwords, goffset *offsets_out, - guint64 *seed) + uint64_t *seed) { guint step_len, remainder, i, out_idx; - guint64 coin, sel; + uint64_t coin, sel; rspamd_stat_token_t *tok; g_assert(nwords != 0); @@ -1232,7 +1232,7 @@ rspamd_language_detector_detect_type(struct rspamd_task *task, goffset *selected_words; rspamd_stat_token_t *tok; guint i; - guint64 seed; + uint64_t seed; /* Seed PRNG with part digest to provide some sort of determinism */ memcpy(&seed, part->mime_part->digest, sizeof(seed)); @@ -1411,14 +1411,14 @@ rspamd_language_detector_unicode_scripts(struct rspamd_task *task, const gchar *p = part->utf_stripped_content->data, *end; guint i = 0, cnt = 0; end = p + part->utf_stripped_content->len; - gint32 uc, sc; + int32_t uc, sc; guint nlatin = 0, nchinese = 0, nspecial = 0; const guint cutoff_limit = 32; while (p + i < end) { U8_NEXT(p, i, part->utf_stripped_content->len, uc); - if (((gint32) uc) < 0) { + if (((int32_t) uc) < 0) { break; } diff --git a/src/libmime/message.c b/src/libmime/message.c index f73c1ee35..f74ca0dca 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -55,7 +55,7 @@ static const gchar gtube_pattern_rewrite_subject[] = "ZJS*C4JDBQADN1.NSBN3*2IDNE static const gchar gtube_pattern_no_action[] = "AJS*C4JDBQADN1.NSBN3*2IDNEN*" "GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"; struct rspamd_multipattern *gtube_matcher = NULL; -static const guint64 words_hash_seed = 0xdeadbabe; +static const uint64_t words_hash_seed = 0xdeadbabe; static void free_byte_array_callback(void *pointer) @@ -76,7 +76,7 @@ rspamd_mime_part_extract_words(struct rspamd_task *task, task->lang_det); for (i = 0; i < part->utf_words->len; i++) { - guint64 h; + uint64_t h; w = &g_array_index(part->utf_words, rspamd_stat_token_t, i); @@ -155,14 +155,14 @@ rspamd_mime_part_create_words(struct rspamd_task *task, const gchar *p = part->utf_stripped_content->data, *end; guint i = 0; end = p + part->utf_stripped_content->len; - gint32 uc, sc; + int32_t uc, sc; tok_type = RSPAMD_TOKENIZE_UTF; while (p + i < end) { U8_NEXT(p, i, part->utf_stripped_content->len, uc); - if (((gint32) uc) < 0) { + if (((int32_t) uc) < 0) { tok_type = RSPAMD_TOKENIZE_RAW; break; } @@ -198,7 +198,7 @@ rspamd_mime_part_create_words(struct rspamd_task *task, if (part->utf_words) { part->normalized_hashes = g_array_sized_new(FALSE, FALSE, - sizeof(guint64), part->utf_words->len); + sizeof(uint64_t), part->utf_words->len); rspamd_normalize_words(part->utf_words, task->task_pool); } } @@ -241,7 +241,7 @@ rspamd_strip_newlines_parse(struct rspamd_task *task, while (p < pe) { if (U8_IS_LEAD(*p) && is_utf) { - gint32 off = p - begin; + int32_t off = p - begin; U8_NEXT(begin, off, pe - begin, uc); if (uc != -1) { @@ -575,7 +575,7 @@ rspamd_words_levenshtein_distance(struct rspamd_task *task, { guint s1len, s2len, x, y, lastdiag, olddiag; guint *column, ret; - guint64 h1, h2; + uint64_t h1, h2; gint eq; static const guint max_words = 8192; @@ -607,8 +607,8 @@ rspamd_words_levenshtein_distance(struct rspamd_task *task, for (y = 1, lastdiag = x - 1; y <= s1len; y++) { olddiag = column[y]; - h1 = g_array_index(w1, guint64, y - 1); - h2 = g_array_index(w2, guint64, x - 1); + h1 = g_array_index(w1, uint64_t, y - 1); + h2 = g_array_index(w2, uint64_t, x - 1); eq = (h1 == h2) ? 1 : 0; /* * Cost of replacement is twice higher than cost of add/delete @@ -1150,7 +1150,7 @@ rspamd_message_parse(struct rspamd_task *task) gsize len; guint i; GError *err = NULL; - guint64 n[2], seed; + uint64_t n[2], seed; if (RSPAMD_TASK_IS_EMPTY(task)) { /* Don't do anything with empty task */ @@ -1722,7 +1722,7 @@ void rspamd_message_unref(struct rspamd_message *msg) void rspamd_message_update_digest(struct rspamd_message *msg, const void *input, gsize len) { - guint64 n[2]; + uint64_t n[2]; /* Sanity */ G_STATIC_ASSERT(sizeof(n) == sizeof(msg->digest)); diff --git a/src/libmime/message.h b/src/libmime/message.h index 52dedaba7..12761bf91 100644 --- a/src/libmime/message.h +++ b/src/libmime/message.h @@ -138,7 +138,7 @@ struct rspamd_mime_text_part { rspamd_ftok_t utf_content; /* utf8 encoded processed content */ GByteArray *utf_raw_content; /* utf raw content */ GByteArray *utf_stripped_content; /* utf content with no newlines */ - GArray *normalized_hashes; /* Array of guint64 */ + GArray *normalized_hashes; /* Array of uint64_t */ GArray *utf_words; /* Array of rspamd_stat_token_t */ UText utf_stripped_text; /* Used by libicu to represent the utf8 content */ diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c index 48a97a4af..90d81b125 100644 --- a/src/libmime/mime_encoding.c +++ b/src/libmime/mime_encoding.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 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, @@ -327,7 +327,7 @@ rspamd_mime_text_to_utf8(rspamd_mempool_t *pool, gsize *olen, GError **err) { gchar *d; - gint32 r, clen, dlen; + int32_t r, clen, dlen; UChar *tmp_buf; UErrorCode uc_err = U_ZERO_ERROR; @@ -407,7 +407,7 @@ rspamd_mime_text_part_utf8_convert(struct rspamd_task *task, GError **err) { gchar *d; - gint32 r, clen, dlen, uc_len; + int32_t r, clen, dlen, uc_len; UChar *tmp_buf; UErrorCode uc_err = U_ZERO_ERROR; UConverter *utf8_converter; @@ -484,7 +484,7 @@ rspamd_mime_to_utf8_byte_array(GByteArray *in, rspamd_mempool_t *pool, const gchar *enc) { - gint32 r, clen, dlen; + int32_t r, clen, dlen; UChar *tmp_buf; UErrorCode uc_err = U_ZERO_ERROR; UConverter *utf8_converter; @@ -568,10 +568,10 @@ void rspamd_mime_charset_utf_enforce(gchar *in, gsize len) while (p < end && len > 0 && (err_offset = rspamd_fast_utf8_validate(p, len)) > 0) { err_offset--; /* As it returns it 1 indexed */ - gint32 cur_offset = err_offset; + int32_t cur_offset = err_offset; while (cur_offset < len) { - gint32 tmp = cur_offset; + int32_t tmp = cur_offset; U8_NEXT(p, cur_offset, len, uc); diff --git a/src/libmime/mime_encoding.h b/src/libmime/mime_encoding.h index ff8129265..88e25efa6 100644 --- a/src/libmime/mime_encoding.h +++ b/src/libmime/mime_encoding.h @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 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, @@ -124,12 +124,12 @@ struct rspamd_charset_converter *rspamd_mime_get_converter_cached( * @param pErrorCode * @return */ -gint32 +int32_t rspamd_converter_to_uchars(struct rspamd_charset_converter *cnv, UChar *dest, - gint32 destCapacity, + int32_t destCapacity, const char *src, - gint32 srcLength, + int32_t srcLength, UErrorCode *pErrorCode); /** diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index e51539ed0..9ff01c3b0 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -175,8 +175,8 @@ const struct rspamd_atom_subr mime_expr_subr = { .destroy = rspamd_mime_expr_destroy}; static struct _fl *list_ptr = &rspamd_functions_list[0]; -static guint32 functions_number = sizeof(rspamd_functions_list) / - sizeof(struct _fl); +static uint32_t functions_number = sizeof(rspamd_functions_list) / + sizeof(struct _fl); static gboolean list_allocated = FALSE; /* Bsearch routine */ diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c index 2bd559d4f..2bdab38c2 100644 --- a/src/libmime/mime_headers.c +++ b/src/libmime/mime_headers.c @@ -37,7 +37,7 @@ static void rspamd_mime_header_check_special(struct rspamd_task *task, struct rspamd_mime_header *rh) { - guint64 h; + uint64_t h; const gchar *p, *end; gchar *id; gint max_recipients = -1, len; @@ -819,7 +819,7 @@ gchar * rspamd_mime_header_encode(const gchar *in, gsize len) { const gchar *p = in, *end = in + len; - gchar *out, encode_buf[80 * sizeof(guint32)]; + gchar *out, encode_buf[80 * sizeof(uint32_t)]; GString *res; gboolean need_encoding = FALSE; @@ -902,15 +902,15 @@ gchar * rspamd_mime_message_id_generate(const gchar *fqdn) { GString *out; - guint64 rnd, clk; + uint64_t rnd, clk; out = g_string_sized_new(strlen(fqdn) + 22); rnd = ottery_rand_uint64(); clk = rspamd_get_calendar_ticks() * 1e6; rspamd_printf_gstring(out, "%*bs.%*bs@%s", - (gint) sizeof(guint64) - 3, (guchar *) &clk, - (gint) sizeof(guint64), (gchar *) &rnd, + (gint) sizeof(uint64_t) - 3, (guchar *) &clk, + (gint) sizeof(uint64_t), (gchar *) &rnd, fqdn); return g_string_free(out, FALSE); diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c index 562a9d7de..64a8a2242 100644 --- a/src/libmime/mime_parser.c +++ b/src/libmime/mime_parser.c @@ -51,8 +51,8 @@ INIT_LOG_MODULE(mime) struct rspamd_mime_boundary { goffset boundary; goffset start; - guint64 hash; - guint64 closed_hash; + uint64_t hash; + uint64_t closed_hash; gint flags; }; @@ -180,7 +180,7 @@ rspamd_mime_parser_init_lib(void) static enum rspamd_cte rspamd_mime_parse_cte(const gchar *in, gsize len) { - guint64 h; + uint64_t h; enum rspamd_cte ret = RSPAMD_CTE_UNKNOWN; in = rspamd_string_len_strip(in, &len, " \t;,.+-#!`~'"); @@ -851,7 +851,7 @@ struct rspamd_mime_multipart_cbdata { struct rspamd_mime_parser_ctx *st; const gchar *part_start; rspamd_ftok_t *cur_boundary; - guint64 bhash; + uint64_t bhash; GError **err; }; diff --git a/src/libmime/smtp_parsers.h b/src/libmime/smtp_parsers.h index e188b6389..e88c2bf54 100644 --- a/src/libmime/smtp_parsers.h +++ b/src/libmime/smtp_parsers.h @@ -42,7 +42,7 @@ rspamd_rfc2047_parser(const gchar *in, gsize len, gint *pencoding, rspamd_inet_addr_t *rspamd_parse_smtp_ip(const char *data, size_t len, rspamd_mempool_t *pool); -guint64 rspamd_parse_smtp_date(const unsigned char *data, size_t len, GError **err); +uint64_t rspamd_parse_smtp_date(const unsigned char *data, size_t len, GError **err); #ifdef __cplusplus } |