aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2022-08-21 19:47:23 +0700
committerMax <msuraev@sysmocom.de>2022-08-22 18:36:51 +0700
commit768f36440fbb1241a53babb0efd5e721ccfe0a28 (patch)
tree2d7281084c3859d6f2796a4c06465fc62e255a1f
parent196ddcbb05e82762a34eb596b5a3bec3b36e962c (diff)
SIGTRAN: error if attempting to send exceedingly big data
Previously DT1 message sent via osmo_sccp_tx_data() was silently truncating data if it was over 256 bytes. Let's fail explicitly and let caller handle this. Related: OS#5579 Change-Id: I8a67bc40080eb1405ab3b0df874e3ea20941a850
-rw-r--r--include/osmocom/sccp/sccp_types.h1
-rw-r--r--src/sccp_helpers.c7
2 files changed, 8 insertions, 0 deletions
diff --git a/include/osmocom/sccp/sccp_types.h b/include/osmocom/sccp/sccp_types.h
index 94b8f0b..63ee568 100644
--- a/include/osmocom/sccp/sccp_types.h
+++ b/include/osmocom/sccp/sccp_types.h
@@ -25,6 +25,7 @@
#include <osmocom/core/utils.h>
#define SCCP_MAX_OPTIONAL_DATA 130
+#define SCCP_MAX_DATA 256
/* Table 1/Q.713 - SCCP message types */
enum sccp_message_types {
diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c
index 266c869..ae7c526 100644
--- a/src/sccp_helpers.c
+++ b/src/sccp_helpers.c
@@ -29,6 +29,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
+#include <osmocom/sccp/sccp_types.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/sigtran/sccp_helpers.h>
@@ -161,6 +162,12 @@ int osmo_sccp_tx_data(struct osmo_sccp_user *scu, uint32_t conn_id,
return -ENOTCONN;
}
+ if (len > SCCP_MAX_DATA) {
+ LOGP(DLSCCP, LOGL_ERROR, "N-DATA.req TX error: amount of data %u > %u - ITU-T Rec. Q.713 ยง4.7 limit\n",
+ len, SCCP_MAX_DATA);
+ return -EMSGSIZE;
+ }
+
msg = scu_msgb_alloc(__func__);
prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
osmo_prim_init(&prim->oph, SCCP_SAP_USER,