That amd64 segfault again
Magnus Holmgren <[email protected]>
| Newsgroups | gmane.mail.spam.spf.devel |
|---|---|
| Organization | Lysator ACS |
| Message-ID | <[email protected]> |
I thought I should attach the patch I'm about to apply to libspf2 in Debian. I started with the patch posted by Thomas Jacob to the Debian bug report (http://bugs.debian.org/392793) and merged with the one from Herbert Straub. Then I moved the changes that just cast the arguments to SPF_Infof() and SPF_Debugf() into a separate patch and instead changed the format strings. But how portable is the z flag to printf()? (From the manpage: "A following integer conversion corresponds to a size_t or ssize_t argument."). -- Magnus Holmgren [email protected] (No Cc of list mail needed, thanks) ------- To unsubscribe, change your address, or temporarily deactivate your subscription, please go to http://v2.listbox.com/member/?list_id=1007
20_64bit_types.dpatch
(text/x-diff, 4.1 KB)
#! /bin/sh /usr/share/dpatch/dpatch-run ## 20_64bit_types.dpatch by <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Change various ints to size_t etc, to avoid crashes on 64-bit ## DP: architectures. @DPATCH@ diff -Nur libspf2-1.2.5.dfsg/src/include/spf_internal.h libspf2-1.2.5.dfsg.new/src/include/spf_internal.h --- libspf2-1.2.5.dfsg/src/include/spf_internal.h 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/include/spf_internal.h 2007-03-23 23:08:54.000000000 +0100 @@ -71,7 +71,7 @@ static inline size_t _align_sz(size_t s) { return (s + (_ALIGN_SZ - 1 - (((s - 1) & (_ALIGN_SZ - 1))))); } static inline char * _align_ptr(char *s) - { return (s + (_ALIGN_SZ - 1 - ((((unsigned int)s - 1) & (_ALIGN_SZ - 1))))); } + { return (s + (_ALIGN_SZ - 1 - ((((size_t)s - 1) & (_ALIGN_SZ - 1))))); } #else static inline size_t _align_sz(size_t s) { return s; } static inline char * _align_ptr(char *s) { return s; } diff -Nur libspf2-1.2.5.dfsg/src/include/spf_record.h libspf2-1.2.5.dfsg.new/src/include/spf_record.h --- libspf2-1.2.5.dfsg/src/include/spf_record.h 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/include/spf_record.h 2007-03-23 23:08:54.000000000 +0100 @@ -224,7 +224,7 @@ struct SPF_macro_struct { - unsigned int macro_len; /* bytes of data */ + size_t macro_len; /* bytes of data */ /* data: (SPF_data_t[] = char[macro_len]) follows */ }; diff -Nur libspf2-1.2.5.dfsg/src/libspf2/spf_compile.c libspf2-1.2.5.dfsg.new/src/libspf2/spf_compile.c --- libspf2-1.2.5.dfsg/src/libspf2/spf_compile.c 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/libspf2/spf_compile.c 2007-03-23 23:18:41.000000000 +0100 @@ -98,7 +98,7 @@ } static void -SPF_c_ensure_capacity(void **datap, int *sizep, int length) +SPF_c_ensure_capacity(void **datap, size_t *sizep, int length) { int size = *sizep; if (length > size) @@ -435,7 +435,7 @@ static SPF_errcode_t SPF_c_parse_macro(SPF_server_t *spf_server, SPF_response_t *spf_response, - SPF_data_t *data, int *data_len, + SPF_data_t *data, size_t *data_len, const char **startp, const char **endp, size_t max_len, SPF_errcode_t big_err, int is_mod) @@ -551,10 +551,10 @@ static SPF_errcode_t SPF_c_parse_domainspec(SPF_server_t *spf_server, SPF_response_t *spf_response, - SPF_data_t *data, int *data_len, + SPF_data_t *data, size_t *data_len, const char **startp, const char **endp, size_t max_len, SPF_errcode_t big_err, - int cidr_ok, int is_mod) + SPF_cidr_t cidr_ok, int is_mod) { SPF_errcode_t err; /* Generic parsing iterators and boundaries */ diff -Nur libspf2-1.2.5.dfsg/src/libspf2/spf_dns_resolv.c libspf2-1.2.5.dfsg.new/src/libspf2/spf_dns_resolv.c --- libspf2-1.2.5.dfsg/src/libspf2/spf_dns_resolv.c 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/libspf2/spf_dns_resolv.c 2007-03-23 23:08:54.000000000 +0100 @@ -393,7 +393,7 @@ if ( SPF_dns_rr_buf_realloc( spfrr, cnt, rdlen ) != SPF_E_SUCCESS ) return spfrr; - dst = spfrr->rr[cnt]->txt; + dst = (u_char *)(spfrr->rr[cnt]->txt); len = 0; src = (u_char *)rdata; while ( rdlen > 0 ) diff -Nur libspf2-1.2.5.dfsg/src/libspf2/spf_interpret.c libspf2-1.2.5.dfsg.new/src/libspf2/spf_interpret.c --- libspf2-1.2.5.dfsg/src/libspf2/spf_interpret.c 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/libspf2/spf_interpret.c 2007-03-23 23:20:30.000000000 +0100 @@ -49,8 +49,8 @@ SPF_record_t *spf_record; SPF_errcode_t err; char *buf; - int buflen; - int len; + size_t buflen; + size_t len; SPF_ASSERT_NOTNULL(spf_response); spf_request = spf_response->spf_request; diff -Nur libspf2-1.2.5.dfsg/src/spfd/spfd.c libspf2-1.2.5.dfsg.new/src/spfd/spfd.c --- libspf2-1.2.5.dfsg/src/spfd/spfd.c 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/spfd/spfd.c 2007-03-23 23:08:54.000000000 +0100 @@ -168,7 +168,7 @@ struct sockaddr_in in; struct sockaddr_un un; } addr; - int addrlen; + socklen_t addrlen; char *data; int datalen;
20_printf_types.dpatch
(text/x-diff, 2.4 KB)
#! /bin/sh /usr/share/dpatch/dpatch-run ## 20_printf_types.dpatch by <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Change the format strings of various calls to printf-style functions to ## DP: match the arguments. @DPATCH@ diff -Nur libspf2-1.2.5.dfsg/src/libspf2/spf_compile.c libspf2-1.2.5.dfsg.new/src/libspf2/spf_compile.c --- libspf2-1.2.5.dfsg/src/libspf2/spf_compile.c 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/libspf2/spf_compile.c 2007-03-23 23:18:41.000000000 +0100 @@ -469,8 +469,8 @@ if ( p + len > end ) /* Don't re-parse the CIDR mask */ len = end - p; if (spf_server->debug) - SPF_debugf("Adding string literal (%d): '%*.*s'", - len, len, len, p); + SPF_debugf("Adding string literal (%zu): '%*.*s'", + len, (int)len, (int)len, p); memcpy( dst, p, len ); ds_len += len; dst += len; diff -Nur libspf2-1.2.5.dfsg/src/libspf2/spf_id2str.c libspf2-1.2.5.dfsg.new/src/libspf2/spf_id2str.c --- libspf2-1.2.5.dfsg/src/libspf2/spf_id2str.c 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/libspf2/spf_id2str.c 2007-03-23 23:13:55.000000000 +0100 @@ -309,7 +309,7 @@ p_end = *bufp + *buflenp; if (debug) - SPF_debugf("stringify: Buffer length is %d\n", *buflenp); + SPF_debugf("stringify: Buffer length is %zu\n", *buflenp); /* diff -Nur libspf2-1.2.5.dfsg/src/libspf2/spf_print.c libspf2-1.2.5.dfsg.new/src/libspf2/spf_print.c --- libspf2-1.2.5.dfsg/src/libspf2/spf_print.c 2007-03-23 22:37:26.000000000 +0100 +++ libspf2-1.2.5.dfsg.new/src/libspf2/spf_print.c 2007-03-23 23:12:30.000000000 +0100 @@ -54,7 +54,7 @@ return SPF_E_SUCCESS; } - SPF_infof( "SPF header: version: %d mech %d/%d mod %d/%d len=%d", + SPF_infof( "SPF header: version: %hhu mech %hhu/%zu mod %hhu/%zu len=%zu", spf_record->version, spf_record->num_mech, spf_record->mech_len, spf_record->num_mod, spf_record->mod_len, @@ -81,7 +81,7 @@ void SPF_print_sizeof(void) { // SPF_infof( "sizeof(SPF_rec_header_t)=%u", sizeof(SPF_rec_header_t)); - SPF_infof( "sizeof(SPF_mech_t)=%u", sizeof(SPF_mech_t)); - SPF_infof( "sizeof(SPF_data_t)=%u", sizeof(SPF_data_t)); - SPF_infof( "sizeof(SPF_mod_t)=%u", sizeof(SPF_mod_t)); + SPF_infof( "sizeof(SPF_mech_t)=%zu", sizeof(SPF_mech_t)); + SPF_infof( "sizeof(SPF_data_t)=%zu", sizeof(SPF_data_t)); + SPF_infof( "sizeof(SPF_mod_t)=%zu", sizeof(SPF_mod_t)); }
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBGBPGNk7mRNn1h4+YRAsexAKC/MWXN+8HYUfjv2yW/xeTeTtAeeQCfRXxn WLEUgcg3YvJzYbVLOE0Pfu8= =S8GO -----END PGP SIGNATURE-----