From: Florian Forster Date: Tue, 21 Apr 2015 08:00:23 +0000 (+0200) Subject: libcollectdclient: Propagate errors when signing / encrypting network packets. X-Git-Tag: collectd-5.5.0~28 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b99f2ef5c262080cdd55d4dc056aaf23ba2ff907;p=collectd.git libcollectdclient: Propagate errors when signing / encrypting network packets. --- diff --git a/src/libcollectdclient/network.c b/src/libcollectdclient/network.c index ddb3b5b9..c390a1ce 100644 --- a/src/libcollectdclient/network.c +++ b/src/libcollectdclient/network.c @@ -1,6 +1,6 @@ /** * collectd - src/libcollectdclient/network.c - * Copyright (C) 2005-2013 Florian Forster + * Copyright (C) 2005-2015 Florian Forster * Copyright (C) 2010 Max Henkel * * Permission is hereby granted, free of charge, to any person obtaining a @@ -219,7 +219,13 @@ static int server_send_buffer (lcc_server_t *srv) /* {{{ */ memset (buffer, 0, sizeof (buffer)); buffer_size = sizeof (buffer); - lcc_network_buffer_finalize (srv->buffer); + status = lcc_network_buffer_finalize (srv->buffer); + if (status != 0) + { + lcc_network_buffer_initialize (srv->buffer); + return (status); + } + status = lcc_network_buffer_get (srv->buffer, buffer, &buffer_size); lcc_network_buffer_initialize (srv->buffer); diff --git a/src/libcollectdclient/network_buffer.c b/src/libcollectdclient/network_buffer.c index 61c7c22e..343c285a 100644 --- a/src/libcollectdclient/network_buffer.c +++ b/src/libcollectdclient/network_buffer.c @@ -1,6 +1,6 @@ /** * collectd - src/libcollectdclient/network_buffer.c - * Copyright (C) 2010-2012 Florian octo Forster + * Copyright (C) 2010-2015 Florian octo Forster * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -792,9 +792,9 @@ int lcc_network_buffer_finalize (lcc_network_buffer_t *nb) /* {{{ */ #if HAVE_LIBGCRYPT if (nb->seclevel == SIGN) - nb_add_signature (nb); + return nb_add_signature (nb); else if (nb->seclevel == ENCRYPT) - nb_add_encryption (nb); + return nb_add_encryption (nb); #endif return (0);