]> git.ipfire.org Git - thirdparty/rspamd.git/commit
Fix DKIM relaxed body canonicalization and optimize performance
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 29 Aug 2025 12:38:01 +0000 (13:38 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 29 Aug 2025 12:40:08 +0000 (13:40 +0100)
commit2f52cdf2e1e58a48bd9e3539feb6441e6f3bf994
treedd0112b64ab2a228092151a2dd13ce04638c9116
parent24b7f2444738eabdc0e0aa3ac3aa1329ca26f31a
Fix DKIM relaxed body canonicalization and optimize performance

This PR addresses critical issues in DKIM relaxed body canonicalization and modernizes the codebase by replacing GLib types with standard C types.

- **RFC Compliance**: Fixed incorrect canonicalization of lines containing only whitespace. Previously, such lines were not properly handled according to RFC 6376, which could lead to DKIM signature verification failures.
- **Memory Safety**: Fixed incorrect pointer dereference in `rspamd_dkim_skip_empty_lines` that could cause undefined behavior.

- **Zero-copy Optimization**: Reimplemented `rspamd_dkim_relaxed_body_step` to avoid unnecessary memory copies. The new implementation:
  - Processes input data directly without intermediate buffers
  - Reduces the number of `EVP_DigestUpdate` calls by processing larger chunks
  - Improves CPU cache efficiency
  - Results in significantly better performance for large email bodies

- Replaced all GLib types with standard C equivalents:
  - `gsize` → `size_t`
  - `gssize` → `ssize_t`
  - `gboolean` → `bool`
  - `TRUE/FALSE` → `true/false`
  - And other GLib-specific types
- Added necessary standard headers (`stdbool.h`, `stdint.h`, `limits.h`)

- Added comprehensive debug logging for:
  - Chunk processing with size information
  - Empty line detection and skipping
  - Space collapsing operations

Issue: #5590
src/libserver/dkim.c
src/libserver/dkim.h