Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES-202605.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ A systematic audit of memory and resource leaks (issue #272) produced fixes acro
- **Python 3 Twisted**: Replaced deprecated `defer.returnValue()` with plain `return` in contrib/repute. (#237)
- **Compiler warning cleanup** (`-Wincompatible-pointer-types`, `-Wformat-truncation`): `entry_name` in the `-V` output path declared `const char *` to match `dkim_nametable_first`/`next` signatures; `snprintf` call sites in `dkim-util.c`, `opendkim.c`, and `opendkim-genzone.c` given explicit `%.*s` width bounds or larger buffers. (#360, issue #359)
- **cppcheck static analysis cleanup**: A grab-bag of small findings from a `cppcheck --enable=warning,style,performance,portability` pass: a dead `ret == -1` recheck duplicated across `libvbr/vbr.c` and `librbl/rbl.c`'s DNS query paths; a `%zd`/`%zu` format string mismatch (and a typo) in `dkim-test.c`'s key-comparison error message; a `size_t` underflow in `dkim_sign()` where `dkim_base64_decode()`'s `int` return (-1 on error) was assigned directly into the `size_t` `dkim_keylen` field; an uninitialized-looking `end` pointer in the "t"/"x" tag validation in `dkim_process_set()`; a dead `if (!first)` conditional in `dkim_getsighdr_d()`'s tag-wrapping loop; and three redundant bounds-check clauses in `dkim_base32_encode()`'s unrolled loop. (#426)
- **`-Wpointer-sign` cleanup, part 1**: A clang build (issue #361) reports 150 `char *`/`u_char *` signedness-mismatch warnings across libopendkim and opendkim. This addresses the two highest-yield sources (38 of the 150) with no behavior change: `dkim_should_signhdrs[]`, `dkim_should_not_signhdrs[]`, and `dkim_required_signhdrs[]` were declared `const u_char *[]` but initialized from ordinary string literals, warning once per entry; retyped to `const char *[]` to match. `dkim_get_header()` took `u_char *name` but is called almost exclusively with string literals; retyped to `char *name`, with a cast added at its one remaining `u_char *`-typed call site (`dkiml_mbs[]`). The remaining ~112 warnings are scattered single-site mismatches needing individual judgment and are left for a follow-up.

---

Expand Down
16 changes: 8 additions & 8 deletions libopendkim/dkim.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void dkim_error (DKIM *, const char *, ...);
#define DKIM_ISLWSP(x) ((x) == 011 || (x) == 013 || (x) == 014 || (x) == 040)

/* recommended list of headers to sign, from RFC6376 Section 5.4 */
const u_char *dkim_should_signhdrs[] =
const char *dkim_should_signhdrs[] =
{
"from",
"reply-to",
Expand All @@ -240,7 +240,7 @@ const u_char *dkim_should_signhdrs[] =
};

/* recommended list of headers not to sign, from RFC6376 Section 5.4 */
const u_char *dkim_should_not_signhdrs[] =
const char *dkim_should_not_signhdrs[] =
{
"return-path",
"received",
Expand All @@ -250,7 +250,7 @@ const u_char *dkim_should_not_signhdrs[] =
};

/* required list of headers to sign */
const u_char *dkim_required_signhdrs[] =
const char *dkim_required_signhdrs[] =
{
"from",
NULL
Expand Down Expand Up @@ -1361,7 +1361,7 @@ dkim_set_getudata(DKIM_SET *set)
*/

static struct dkim_header *
dkim_get_header(DKIM *dkim, u_char *name, size_t namelen, int inst)
dkim_get_header(DKIM *dkim, char *name, size_t namelen, int inst)
{
size_t len;
struct dkim_header *hdr;
Expand All @@ -1370,15 +1370,15 @@ dkim_get_header(DKIM *dkim, u_char *name, size_t namelen, int inst)
assert(name != NULL);

if (namelen == 0)
len = strlen((char *) name);
len = strlen(name);
else
len = namelen;

for (hdr = dkim->dkim_hhead; hdr != NULL; hdr = hdr->hdr_next)
{
if (hdr->hdr_namelen == len &&
strncasecmp((char *) hdr->hdr_text,
(char *) name, len) == 0)
name, len) == 0)
{
if (inst == 0)
return hdr;
Expand Down Expand Up @@ -4151,7 +4151,7 @@ dkim_eom_verify(DKIM *dkim, _Bool *testkey)
u_char *domain;
u_char *user;

hdr = dkim_get_header(dkim, (u_char *) DKIM_FROMHEADER,
hdr = dkim_get_header(dkim, DKIM_FROMHEADER,
DKIM_FROMHEADER_LEN, 0);
if (hdr == NULL)
{
Expand Down Expand Up @@ -6162,7 +6162,7 @@ dkim_sig_process(DKIM *dkim, DKIM_SIGINFO *sig)
for (c = 0; dkim->dkim_libhandle->dkiml_mbs[c] != NULL; c++)
{
if (dkim_get_header(dkim,
dkim->dkim_libhandle->dkiml_mbs[c],
(char *) dkim->dkim_libhandle->dkiml_mbs[c],
0, 0) != NULL &&
!dkim_sig_hdrsigned(sig,
dkim->dkim_libhandle->dkiml_mbs[c]))
Expand Down
4 changes: 2 additions & 2 deletions libopendkim/dkim.h
Original file line number Diff line number Diff line change
Expand Up @@ -1981,10 +1981,10 @@ extern const char *dkim_getsslbuf (DKIM *dkim);
extern const char *dkim_sig_getsslbuf (DKIM_SIGINFO *sig);

/* list of headers that should be signed, per RFC6376 Section 5.4 */
extern const u_char *dkim_should_signhdrs[];
extern const char *dkim_should_signhdrs[];

/* list of headers that should not be signed, per RFC6376 Section 5.4 */
extern const u_char *dkim_should_not_signhdrs[];
extern const char *dkim_should_not_signhdrs[];

/*
** DKIM_CODE_TO_NAME -- translate a mnemonic code to its name
Expand Down
Loading