Skip to content

Commit 087d44e

Browse files
authored
fix: resolve char/u_char pointer-sign compiler warnings (#426)
Adds explicit casts at the char*/u_char* boundary throughout libopendmarc and the milter, eliminating -Wpointer-sign and a stray nested-comment warning surfaced by a non-CI build (CI suppresses these via -Wno-pointer-sign). Also drops two backwards casts on dfc->mctx_jobid (char *) and fixes a real -Wincompatible-pointer-types mismatch in the ignorereceivers history path.
1 parent 479cb20 commit 087d44e

8 files changed

Lines changed: 197 additions & 198 deletions

File tree

libopendmarc/opendmarc_policy.c

Lines changed: 67 additions & 67 deletions
Large diffs are not rendered by default.

libopendmarc/opendmarc_tld.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ opendmarc_reverse_domain(u_char *domain, u_char *buf, size_t buflen)
4747
if (*cp != '.')
4848
break;
4949
}
50-
if (strlen(cp) == 0)
50+
if (strlen((char *)cp) == 0)
5151
{
5252
return EINVAL;
5353
}
5454
if (cp > domain)
5555
--cp;
5656
(void) memset((char *)copy, '\0', sizeof copy);
57-
(void) strlcpy((char *)copy, cp, sizeof copy);
57+
(void) strlcpy((char *)copy, (char *)cp, sizeof copy);
5858
ep = copy + strlen((char *)copy);
5959

6060
/*
@@ -188,7 +188,7 @@ opendmarc_tld_read_file(char *path_fname, char *commentstring, char *drop, char
188188
if (adddot == TRUE)
189189
(void) strlcat((char *)revbuf, ".", sizeof revbuf);
190190

191-
if (opendmarc_hash_lookup(hashp, revbuf, (void *)revbuf, strlen(revbuf)) == NULL)
191+
if (opendmarc_hash_lookup(hashp, (char *)revbuf, (void *)revbuf, strlen((char *)revbuf)) == NULL)
192192
return 1;
193193
nlines++;
194194
}
@@ -261,16 +261,16 @@ opendmarc_get_tld(u_char *domain, u_char *tld, size_t tld_len)
261261
/*
262262
** No tld list was supplied so copy the domain and return.
263263
*/
264-
(void) strlcpy(tld, domain, tld_len);
264+
(void) strlcpy((char *)tld, (char *)domain, tld_len);
265265
return 0;
266266
}
267267

268-
for (rp = revbuf + strlen(revbuf) -1; rp > revbuf; --rp)
268+
for (rp = revbuf + strlen((char *)revbuf) -1; rp > revbuf; --rp)
269269
{
270270
if (rp == revbuf)
271271
{
272272
/* no match found in the hash table. */
273-
(void) strlcpy(tld, domain, tld_len);
273+
(void) strlcpy((char *)tld, (char *)domain, tld_len);
274274
break;
275275
}
276276
if (*rp == '.')
@@ -280,7 +280,7 @@ opendmarc_get_tld(u_char *domain, u_char *tld, size_t tld_len)
280280
# if HAVE_PTHREAD_H || HAVE_PTHREAD
281281
(void) pthread_mutex_lock(&TLD_hctx_mutex);
282282
# endif
283-
vp = opendmarc_hash_lookup(TLD_hctx, revbuf, NULL, 0);
283+
vp = opendmarc_hash_lookup(TLD_hctx, (char *)revbuf, NULL, 0);
284284
# if HAVE_PTHREAD_H || HAVE_PTHREAD
285285
(void) pthread_mutex_unlock(&TLD_hctx_mutex);
286286
# endif
@@ -295,13 +295,13 @@ opendmarc_get_tld(u_char *domain, u_char *tld, size_t tld_len)
295295
# if HAVE_PTHREAD_H || HAVE_PTHREAD
296296
(void) pthread_mutex_lock(&TLD_hctx_mutex);
297297
# endif
298-
vp = opendmarc_hash_lookup(TLD_hctx, revbuf, NULL, 0);
298+
vp = opendmarc_hash_lookup(TLD_hctx, (char *)revbuf, NULL, 0);
299299
# if HAVE_PTHREAD_H || HAVE_PTHREAD
300300
(void) pthread_mutex_unlock(&TLD_hctx_mutex);
301301
# endif
302302
if (vp != NULL)
303303
{
304-
char * cp = strchr(revbuf, '.');
304+
char * cp = strchr((char *)revbuf, '.');
305305

306306
if (cp == NULL)
307307
*rp = '.';

libopendmarc/opendmarc_util.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ opendmarc_util_pushargv(u_char *str, u_char **ary, int *cnt)
7676
{
7777
return NULL;
7878
}
79-
ary[0] = strdup(str);
79+
ary[0] = (u_char *)strdup((char *)str);
8080
ary[1] = NULL;
8181
if (ary[0] == NULL)
8282
{
@@ -104,7 +104,7 @@ opendmarc_util_pushargv(u_char *str, u_char **ary, int *cnt)
104104
return NULL;
105105
}
106106
ary = tmp;
107-
ary[i] = strdup(str);
107+
ary[i] = (u_char *)strdup((char *)str);
108108
if (ary[i] == NULL)
109109
{
110110
ary = opendmarc_util_clearargv(ary);
@@ -168,7 +168,7 @@ opendmarc_util_cleanup(u_char *str, u_char *buf, size_t buflen)
168168

169169
(void) memset(buf, '\0', buflen);
170170

171-
for (sp = str, ep = buf; *sp != '\0'; sp++)
171+
for (sp = (char *)str, ep = (char *)buf; *sp != '\0'; sp++)
172172
{
173173
if (!isascii(*sp) || !isspace(*sp))
174174
*ep++ = *sp;
@@ -214,7 +214,7 @@ opendmarc_util_finddomain(u_char *raw, u_char *buf, size_t buflen)
214214
len = strlen((char *)raw);
215215
if (len > BUFSIZ)
216216
len = BUFSIZ - 1;
217-
(void) strncpy(copy, raw, len);
217+
(void) strncpy((char *)copy, (char *)raw, len);
218218

219219
/*
220220
* Quoted commas do not delimit addresses.
@@ -354,7 +354,7 @@ opendmarc_util_finddomain(u_char *raw, u_char *buf, size_t buflen)
354354
strip_local_part:
355355
if (cp == NULL)
356356
cp = copy;
357-
ep = strchr(cp, '@');
357+
ep = (u_char *)strchr((char *)cp, '@');
358358
if (ep != NULL)
359359
cp = ep + 1;
360360
len = strlen((char *)cp);
@@ -370,7 +370,7 @@ opendmarc_util_finddomain(u_char *raw, u_char *buf, size_t buflen)
370370
if (*ep == '.')
371371
*ep = '\0';
372372
}
373-
(void) strlcpy(buf, cp, buflen);
373+
(void) strlcpy((char *)buf, (char *)cp, buflen);
374374
return buf;
375375
}
376376

opendmarc/opendmarc-arcares.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ opendmarc_arcares_strip_whitespace(u_char *string)
120120
/* set remaining chars to null */
121121
memset(&string[a], '\0', b - a);
122122

123-
return string;
123+
return (char *)string;
124124
}
125125

126126
/*
@@ -196,7 +196,7 @@ opendmarc_arcares_arc_parse (struct arcares *aar,
196196
if (p_found++)
197197
return -1;
198198

199-
strlcpy(arc->smtpclientip,
199+
strlcpy((char *)arc->smtpclientip,
200200
(char *) arc->arcresult.result_value[cp],
201201
sizeof arc->smtpclientip);
202202
}

opendmarc/opendmarc-arcseal.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ opendmarc_arcseal_strip_whitespace(u_char *string)
113113
/* set remaining chars to null */
114114
memset(&string[a], '\0', b - a);
115115

116-
return string;
116+
return (char *)string;
117117
}
118118

119119
/*
@@ -145,54 +145,54 @@ opendmarc_arcseal_parse(u_char *hdr, struct arcseal *as)
145145
memset(tmp, '\0', sizeof tmp);
146146

147147
// guarantee a null-terminated string
148-
memcpy(tmp, hdr, MIN(strlen(hdr), sizeof tmp - 1));
148+
memcpy(tmp, hdr, MIN(strlen((char *)hdr), sizeof tmp - 1));
149149

150-
while ((token = strsep((char **)&tmp_ptr, ";")) != NULL)
150+
while ((token = (u_char *)strsep((char **)&tmp_ptr, ";")) != NULL)
151151
{
152152
size_t leading_space_len;
153153
as_tag_t tag_code;
154154
char *token_ptr;
155155
char *tag_label;
156156
char *tag_value;
157157

158-
leading_space_len = strspn(token, " \r\n\t");
159-
token_ptr = token + leading_space_len;
158+
leading_space_len = strspn((char *)token, " \r\n\t");
159+
token_ptr = (char *)token + leading_space_len;
160160
if (*token_ptr == '\0')
161161
return 0;
162162
tag_label = strsep(&token_ptr, "=");
163163
if (token_ptr == NULL)
164164
return -1;
165-
tag_value = opendmarc_arcseal_strip_whitespace(token_ptr);
165+
tag_value = opendmarc_arcseal_strip_whitespace((u_char *)token_ptr);
166166
tag_code = opendmarc_arcseal_convert(as_tags, tag_label);
167167

168168
switch (tag_code)
169169
{
170170
case AS_TAG_ALGORITHM:
171-
strlcpy(as->algorithm, tag_value, sizeof as->algorithm);
171+
strlcpy((char *)as->algorithm, tag_value, sizeof as->algorithm);
172172
break;
173173

174174
case AS_TAG_CHAIN_VALIDATION:
175-
strlcpy(as->chain_validation, tag_value, sizeof as->chain_validation);
175+
strlcpy((char *)as->chain_validation, tag_value, sizeof as->chain_validation);
176176
break;
177177

178178
case AS_TAG_INSTANCE:
179179
as->instance = atoi(tag_value);
180180
break;
181181

182182
case AS_TAG_SIGNATURE_DOMAIN:
183-
strlcpy(as->signature_domain, tag_value, sizeof as->signature_domain);
183+
strlcpy((char *)as->signature_domain, tag_value, sizeof as->signature_domain);
184184
break;
185185

186186
case AS_TAG_SIGNATURE_SELECTOR:
187-
strlcpy(as->signature_selector, tag_value, sizeof as->signature_selector);
187+
strlcpy((char *)as->signature_selector, tag_value, sizeof as->signature_selector);
188188
break;
189189

190190
case AS_TAG_SIGNATURE_TIME:
191-
strlcpy(as->signature_time, tag_value, sizeof as->signature_time);
191+
strlcpy((char *)as->signature_time, tag_value, sizeof as->signature_time);
192192
break;
193193

194194
case AS_TAG_SIGNATURE_VALUE:
195-
strlcpy(as->signature_value, tag_value, sizeof as->signature_value);
195+
strlcpy((char *)as->signature_value, tag_value, sizeof as->signature_value);
196196
break;
197197

198198
default:

opendmarc/opendmarc-check.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ main(int argc, char **argv)
9292
return EX_SOFTWARE;
9393
}
9494

95-
dmarc = opendmarc_policy_connect_init(LOCALHOST, FALSE);
95+
dmarc = opendmarc_policy_connect_init((u_char *)LOCALHOST, FALSE);
9696
if (dmarc == NULL)
9797
{
9898
fprintf(stderr, "%s: opendmarc_policy_connect_init() failed\n",
@@ -105,7 +105,7 @@ main(int argc, char **argv)
105105
{
106106
(void) opendmarc_policy_connect_rset(dmarc);
107107

108-
status = opendmarc_policy_store_from_domain(dmarc, argv[c]);
108+
status = opendmarc_policy_store_from_domain(dmarc, (u_char *)argv[c]);
109109
if (status != DMARC_PARSE_OKAY)
110110
{
111111
fprintf(stderr,

0 commit comments

Comments
 (0)