This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/19218 ) Change subject: Detect truncated reads on SOCK_SEQPACKET sockets ...................................................................... Detect truncated reads on SOCK_SEQPACKET sockets Related: OS#4663 Change-Id: Ie143d3d56a68fda97cb9f5107a27f9beb043a2a4 --- M src/intf_line.c 1 file changed, 16 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified tnt: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/src/intf_line.c b/src/intf_line.c index ce30b4f..fe9edbb 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -26,6 +26,9 @@ #include <unistd.h> #include <stdint.h> #include <string.h> +#include <sys/types.h> +#include <sys/socket.h> + #include <talloc.h> #include <osmocom/core/isdnhdlc.h> @@ -179,8 +182,14 @@ while (oo < len) { /* Pending message ? */ if (!ts->tx_len) { - rv = read(ts->fd, ts->tx_buf, sizeof(ts->tx_buf)); + rv = recv(ts->fd, ts->tx_buf, sizeof(ts->tx_buf), MSG_TRUNC); if (rv > 0) { + if (rv > sizeof(ts->tx_buf)) { + LOGPTS(ts, DXFR, LOGL_ERROR, "Truncated message: Client tried to " + "send %d bytes but our buffer is limited to %lu\n", + rv, sizeof(ts->tx_buf)); + rv = sizeof(ts->tx_buf); + } LOGPTS(ts, DXFR, LOGL_DEBUG, "TX Message: %d [ %s]\n", rv, osmo_hexdump(ts->tx_buf, rv)); ts->tx_len = rv; @@ -242,7 +251,12 @@ switch (ts->mode) { case E1_TS_MODE_RAW: - l = read(ts->fd, buf_ts, fts); + l = recv(ts->fd, buf_ts, fts, MSG_TRUNC); + if (l > fts) { + LOGPTS(ts, DXFR, LOGL_ERROR, "Truncated message: Client tried to " + "send %d bytes but our buffer is limited to %d\n", l, fts); + l = fts; + } break; case E1_TS_MODE_HDLCFCS: l = _e1_tx_hdlcfs(ts, buf_ts, fts); -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/19218 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: Ie143d3d56a68fda97cb9f5107a27f9beb043a2a4 Gerrit-Change-Number: 19218 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-Reviewer: tnt <tnt at 246tNt.com> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200712/76f72499/attachment.htm>