From 0d5408caf8f1586b37b273ed4b1f38b24c411846 Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 29 Aug 2021 20:46:16 +0300 Subject: Update to Debian 11 versions of dependencies Now it builds with newer compiler and library versions, the ones from Debian 11 repositories. --- README | 2 +- configure.ac | 5 +++++ examples/basic.c | 5 +++-- src/Makefile.am | 15 ++++++++++++--- src/rexmpp.c | 20 ++++++++------------ 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/README b/README index 8603d3d..afe9589 100644 --- a/README +++ b/README @@ -15,7 +15,7 @@ of implementing additional XEPs on top of it, and should try to make it easy to implement a decent client application using it. Current dependencies: libunbound, libxml2, gnutls, gnutls-dane, gsasl, -gpgme, libicu. +gpgme, libicu, nettle. A rough roadmap: diff --git a/configure.ac b/configure.ac index c175e74..f88deb1 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,11 @@ PKG_CHECK_MODULES([ICU_I18N], [icu-i18n]) AC_SUBST(ICU_I18N_CFLAGS) AC_SUBST(ICU_I18N_LIBS) +PKG_CHECK_MODULES([NETTLE], [nettle]) +AC_SUBST(NETTLE_CFLAGS) +AC_SUBST(NETTLE_LIBS) + + # Checks for header files. AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h syslog.h]) diff --git a/examples/basic.c b/examples/basic.c index 55597a8..e122ee8 100644 --- a/examples/basic.c +++ b/examples/basic.c @@ -80,8 +80,9 @@ int my_xml_out_cb (rexmpp_t *s, xmlNodePtr node) { return 0; } -void my_console_print_cb (rexmpp_t *s, const char *fmt, va_list args) { +int my_console_print_cb (rexmpp_t *s, const char *fmt, va_list args) { vprintf(fmt, args); + return 0; } void print_help (char *prog_name) { @@ -94,7 +95,7 @@ void print_help (char *prog_name) { , prog_name); } -main (int argc, char **argv) { +int main (int argc, char **argv) { int c, xml_console = 0, txt_console = 0, log = 0; if (argc < 2) { print_help(argv[0]); diff --git a/src/Makefile.am b/src/Makefile.am index 3ff5e02..ea6e1a5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,6 @@ AM_CFLAGS = -Werror -Wall -Wextra -pedantic -std=gnu99 \ - -Wno-pointer-sign + -Wno-pointer-sign \ + -Wno-stringop-truncation -Wno-stringop-overflow -Wno-maybe-uninitialized # -Wno-pointer-sign is used to suppress libxml2-related warnings. # Since we only care about UTF-8, and in almost all cases just its @@ -7,6 +8,13 @@ AM_CFLAGS = -Werror -Wall -Wextra -pedantic -std=gnu99 \ # etc), it shouldn't matter. Later it would be nice to abstract XML # manipulations anyway, to allow libexpat as an alternative. +# -Wno-stringop-truncation, -Wno-stringop-overflow, and +# -Wno-maybe-uninitialized are added because newer GCC versions +# started complaining about the bits that are fine, though rewriting +# those bits in a way that doesn't make GCC unhappy may be useful for +# catching actual bugs with those warnings. + + lib_LTLIBRARIES = librexmpp.la librexmpp_la_SOURCES = rexmpp_roster.h rexmpp_roster.c \ @@ -22,6 +30,7 @@ include_HEADERS = rexmpp_roster.h rexmpp_tcp.h rexmpp_socks.h rexmpp.h \ rexmpp_dns.h rexmpp_jid.h rexmpp_openpgp.h rexmpp_console.h rexmpp_pubsub.h librexmpp_la_CFLAGS = $(AM_CFLAGS) $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) \ $(LIBDANE_CFLAGS) $(GSASL_CFLAGS) $(UNBOUND_CFLAGS) $(GPGME_CFLAGS) - $(ICU_I18N_CFLAGS) + $(ICU_I18N_CFLAGS) $(NETTLE_CFLAGS) librexmpp_la_LIBADD = $(LIBXML_LIBS) $(GNUTLS_LIBS) $(LIBDANE_LIBS) \ - $(GSASL_LIBS) $(UNBOUND_LIBS) $(GPGME_LIBS) $(ICU_I18N_LIBS) + $(GSASL_LIBS) $(UNBOUND_LIBS) $(GPGME_LIBS) $(ICU_I18N_LIBS) \ + $(NETTLE_LIBS) diff --git a/src/rexmpp.c b/src/rexmpp.c index c87c379..d8a67c8 100644 --- a/src/rexmpp.c +++ b/src/rexmpp.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "rexmpp.h" #include "rexmpp_tcp.h" @@ -195,20 +196,15 @@ char *rexmpp_capabilities_string (rexmpp_t *s, xmlNodePtr info) { char *rexmpp_capabilities_hash (rexmpp_t *s, xmlNodePtr info) { - int err; - char *hash; + struct sha1_ctx ctx; + sha1_init(&ctx); + char hash[SHA1_DIGEST_SIZE]; char *str = rexmpp_capabilities_string(s, info); - err = gsasl_sha1(str, strlen(str), &hash); - free(str); - if (err) { - rexmpp_log(s, LOG_ERR, "Hashing failure: %s", - gsasl_strerror(err)); - return NULL; - } + sha1_update(&ctx, strlen(str), str); + sha1_digest(&ctx, SHA1_DIGEST_SIZE, hash); char *out = NULL; size_t out_len = 0; - gsasl_base64_to(hash, 20, &out, &out_len); - free(hash); + gsasl_base64_to(hash, SHA1_DIGEST_SIZE, &out, &out_len); return out; } @@ -472,7 +468,7 @@ rexmpp_err_t rexmpp_init (rexmpp_t *s, ub_strerror(err)); } /* todo: better to make this path configurable, not to hardcode it */ - err = ub_ctx_trustedkeys(s->resolver_ctx, "/etc/unbound/root.key"); + err = ub_ctx_add_ta_file(s->resolver_ctx, "/usr/share/dns/root.key"); if (err != 0) { rexmpp_log(s, LOG_WARNING, "Failed to set root key file for DNSSEC: %s", ub_strerror(err)); -- cgit v1.2.3