On Thu, Aug 17, 2023 at 10:52:17PM +0100, Adam D. Barratt wrote: > Please supply an appropriate debdiff.
Sorry for the confusion, here is an updated debdiff. Thank you! -- Romain Tartière <rom...@blogreen.org> http://romain.blogreen.org/ pgp: 8234 9A78 E7C0 B807 0B59 80FF BA4D 1D95 5112 336F (ID: 0x5112336F) (plain text =non-HTML= PGP/GPG encrypted/signed e-mail much appreciated)
diff -Nru riemann-c-client-1.10.4/debian/changelog riemann-c-client-1.10.4/debian/changelog --- riemann-c-client-1.10.4/debian/changelog 2019-01-03 07:09:25.000000000 -1000 +++ riemann-c-client-1.10.4/debian/changelog 2023-08-19 10:21:25.000000000 -1000 @@ -1,3 +1,9 @@ +riemann-c-client (1.10.4-2+deb11u1) bullseye; urgency=medium + + * Fix GnuTLS send/recv. + + -- Romain Tartirère <rom...@blogreen.org> Sat, 19 Aug 2023 10:21:25 -1000 + riemann-c-client (1.10.4-2) unstable; urgency=medium * Orphaning the package. diff -Nru riemann-c-client-1.10.4/debian/patches/fix-gnutls-send-recv-when-return-eagain riemann-c-client-1.10.4/debian/patches/fix-gnutls-send-recv-when-return-eagain --- riemann-c-client-1.10.4/debian/patches/fix-gnutls-send-recv-when-return-eagain 1969-12-31 14:00:00.000000000 -1000 +++ riemann-c-client-1.10.4/debian/patches/fix-gnutls-send-recv-when-return-eagain 2023-08-19 10:21:24.000000000 -1000 @@ -0,0 +1,46 @@ +Origin: upstream, 9e382db87bd1703423760bbe104a66e7cdfcf5a6 +Description: Fix GnuTLS send/recv when returning GNUTLS_E_AGAIN + Some values returned from gnutls_record_send() / gnutls_record_recv() indicate + that the operation could not be done. In such cases, the error should not + propagate to the caller but be operation should be retried. + . + Upstream fixed this issue in 9e382db87bd1703423760bbe104a66e7cdfcf5a6 with a + lot more changes, so this patch only fix the wrong behavior. +Author: Romain Tartière <rom...@blogreen.org> +Forwarded: not-needed +--- +--- riemann-c-client-1.10.4.orig/lib/riemann/client/tls-gnutls.c ++++ riemann-c-client-1.10.4/lib/riemann/client/tls-gnutls.c +@@ -202,7 +202,9 @@ _riemann_client_send_message_tls (rieman + if (!buffer) + return -errno; + +- sent = gnutls_record_send (client->tls.session, buffer, len); ++ do { ++ sent = gnutls_record_send (client->tls.session, buffer, len); ++ } while (sent == GNUTLS_E_AGAIN || sent == GNUTLS_E_INTERRUPTED); + if (sent < 0 || (size_t)sent != len) + { + free (buffer); +@@ -220,7 +222,9 @@ _riemann_client_recv_message_tls (rieman + ssize_t received; + riemann_message_t *message; + +- received = gnutls_record_recv (client->tls.session, &header, sizeof (header)); ++ do { ++ received = gnutls_record_recv (client->tls.session, &header, sizeof (header)); ++ } while (received == GNUTLS_E_AGAIN || received == GNUTLS_E_INTERRUPTED); + if (received != sizeof (header)) + { + errno = EPROTO; +@@ -230,7 +234,9 @@ _riemann_client_recv_message_tls (rieman + + buffer = (uint8_t *) malloc (len); + +- received = gnutls_record_recv (client->tls.session, buffer, len); ++ do { ++ received = gnutls_record_recv (client->tls.session, buffer, len); ++ } while (received == GNUTLS_E_AGAIN || received == GNUTLS_E_INTERRUPTED); + if (received != len) + { + free (buffer); diff -Nru riemann-c-client-1.10.4/debian/patches/fix-gnutls-send-recv-when-return-less-than-expected riemann-c-client-1.10.4/debian/patches/fix-gnutls-send-recv-when-return-less-than-expected --- riemann-c-client-1.10.4/debian/patches/fix-gnutls-send-recv-when-return-less-than-expected 1969-12-31 14:00:00.000000000 -1000 +++ riemann-c-client-1.10.4/debian/patches/fix-gnutls-send-recv-when-return-less-than-expected 2023-08-19 10:21:24.000000000 -1000 @@ -0,0 +1,91 @@ +Description: Fix GnuTLS send/recv when returning a lower value than expected + gnutls_record_send() / gnutls_record_recv() may be interrupted after some data + transmission but before the message was completely read/written. When this + happen, the value returned by the function is positive but lower that the size + of the read/write. In this case, we should not return an error, but rather + loop to recv/send the missing data. +Author: Romain Tartière <rom...@blogreen.org> +Forwarded: https://git.madhouse-project.org/algernon/riemann-c-client/pulls/14 +--- +--- riemann-c-client-1.10.4.orig/lib/riemann/client/tls-gnutls.c ++++ riemann-c-client-1.10.4/lib/riemann/client/tls-gnutls.c +@@ -202,13 +202,18 @@ _riemann_client_send_message_tls (rieman + if (!buffer) + return -errno; + +- do { +- sent = gnutls_record_send (client->tls.session, buffer, len); +- } while (sent == GNUTLS_E_AGAIN || sent == GNUTLS_E_INTERRUPTED); +- if (sent < 0 || (size_t)sent != len) ++ size_t left = len; ++ while (left > 0) + { +- free (buffer); +- return -EPROTO; ++ do { ++ sent = gnutls_record_send (client->tls.session, buffer + len - left, left); ++ } while (sent == GNUTLS_E_AGAIN || sent == GNUTLS_E_INTERRUPTED); ++ if (sent < 0) ++ { ++ free (buffer); ++ return -EPROTO; ++ } ++ left -= sent; + } + free (buffer); + return 0; +@@ -220,28 +225,41 @@ _riemann_client_recv_message_tls (rieman + uint32_t header, len; + uint8_t *buffer; + ssize_t received; ++ size_t left; + riemann_message_t *message; + +- do { +- received = gnutls_record_recv (client->tls.session, &header, sizeof (header)); +- } while (received == GNUTLS_E_AGAIN || received == GNUTLS_E_INTERRUPTED); +- if (received != sizeof (header)) ++ len = sizeof (header); ++ left = len; ++ while (left > 0) + { +- errno = EPROTO; +- return NULL; ++ do { ++ received = gnutls_record_recv (client->tls.session, &header + len - left, left); ++ } while (received == GNUTLS_E_AGAIN || received == GNUTLS_E_INTERRUPTED); ++ if (received <= 0) ++ { ++ errno = EPROTO; ++ return NULL; ++ } ++ left -= received; + } ++ + len = ntohl (header); + + buffer = (uint8_t *) malloc (len); + +- do { +- received = gnutls_record_recv (client->tls.session, buffer, len); +- } while (received == GNUTLS_E_AGAIN || received == GNUTLS_E_INTERRUPTED); +- if (received != len) ++ left = len; ++ while (left > 0) + { +- free (buffer); +- errno = EPROTO; +- return NULL; ++ do { ++ received = gnutls_record_recv (client->tls.session, buffer + len - left, left); ++ } while (received == GNUTLS_E_AGAIN || received == GNUTLS_E_INTERRUPTED); ++ if (received <= 0) ++ { ++ free (buffer); ++ errno = EPROTO; ++ return NULL; ++ } ++ left -= received; + } + + message = riemann_message_from_buffer (buffer, len); diff -Nru riemann-c-client-1.10.4/debian/patches/series riemann-c-client-1.10.4/debian/patches/series --- riemann-c-client-1.10.4/debian/patches/series 1969-12-31 14:00:00.000000000 -1000 +++ riemann-c-client-1.10.4/debian/patches/series 2023-08-19 10:21:24.000000000 -1000 @@ -0,0 +1,2 @@ +fix-gnutls-send-recv-when-return-eagain +fix-gnutls-send-recv-when-return-less-than-expected
signature.asc
Description: PGP signature