Change in ...osmo-msc[master]: libmsc/db.c: warn user about SMS text truncation
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-msc/+/13489 ) Change subject: libmsc/db.c: warn user about SMS text truncation .. Patch Set 7: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/13489 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I75e852ebe44ba4784572cbffa029e13f0d3c430c Gerrit-Change-Number: 13489 Gerrit-PatchSet: 7 Gerrit-Owner: fixeria Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Comment-Date: Thu, 06 Jun 2019 19:45:15 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in ...osmo-msc[master]: libmsc/db.c: warn user about SMS text truncation
laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-msc/+/13489 ) Change subject: libmsc/db.c: warn user about SMS text truncation .. libmsc/db.c: warn user about SMS text truncation In general, neither TP-User-Data nor decoded text should be truncated. If the SMSC's database for some reason does contain such weird messages, let's at least let the user know about it. Change-Id: I75e852ebe44ba4784572cbffa029e13f0d3c430c --- M src/libmsc/db.c 1 file changed, 10 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/libmsc/db.c b/src/libmsc/db.c index a12889b..705af61 100644 --- a/src/libmsc/db.c +++ b/src/libmsc/db.c @@ -229,6 +229,7 @@ { const unsigned char *user_data; unsigned int user_data_len; + unsigned int text_len; const char *text; /* Retrieve TP-UDL (User-Data-Length) in octets (regardless of DCS) */ @@ -247,6 +248,15 @@ memcpy(sms->user_data, user_data, user_data_len); } + /* Retrieve the text length (excluding '\0') */ + text_len = dbi_result_get_field_length(result, "text"); + if (text_len >= sizeof(sms->text)) { + LOGP(DDB, LOGL_ERROR, +"SMS text length %u is too big, truncating to %zu\n", +text_len, sizeof(sms->text) - 1); + /* OSMO_STRLCPY_ARRAY() does truncation for us */ + } + /* Retrieve the text parsed from TP-UD (User-Data) */ text = dbi_result_get_string(result, "text"); if (text) -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/13489 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I75e852ebe44ba4784572cbffa029e13f0d3c430c Gerrit-Change-Number: 13489 Gerrit-PatchSet: 8 Gerrit-Owner: fixeria Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-MessageType: merged
Change in ...osmo-msc[master]: libmsc/db.c: warn user about SMS text truncation
Harald Welte has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-msc/+/13489 ) Change subject: libmsc/db.c: warn user about SMS text truncation .. Patch Set 7: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/13489 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Change-Id: I75e852ebe44ba4784572cbffa029e13f0d3c430c Gerrit-Change-Number: 13489 Gerrit-PatchSet: 7 Gerrit-Owner: fixeria Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Comment-Date: Tue, 04 Jun 2019 21:36:17 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-msc[master]: libmsc/db.c: warn user about SMS text truncation
Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/13489 Change subject: libmsc/db.c: warn user about SMS text truncation .. libmsc/db.c: warn user about SMS text truncation In general, neither TP-User-Data nor decoded text should be truncated. If the SMSC's database for some reason does contain such weird messages, let's at least let the user know about it. Change-Id: I75e852ebe44ba4784572cbffa029e13f0d3c430c --- M src/libmsc/db.c 1 file changed, 10 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/89/13489/1 diff --git a/src/libmsc/db.c b/src/libmsc/db.c index bf57ec8..6cd8493 100644 --- a/src/libmsc/db.c +++ b/src/libmsc/db.c @@ -229,6 +229,7 @@ { const unsigned char *user_data; unsigned int user_data_len; + unsigned int text_len; const char *text; /* Retrieve TP-UDL (User-Data-Length) in octets (regardless of DCS) */ @@ -245,6 +246,15 @@ user_data = dbi_result_get_binary(result, "user_data"); memcpy(sms->user_data, user_data, user_data_len); + /* Retrieve the text length (excluding '\0') */ + text_len = dbi_result_get_field_length(result, "text"); + if (text_len >= sizeof(sms->text)) { + LOGP(DDB, LOGL_ERROR, +"SMS text length %u is too big, truncating to %zu\n", +text_len, sizeof(sms->text) - 1); + /* OSMO_STRLCPY_ARRAY() does truncation for us */ + } + /* Retrieve the text parsed from TP-UD (User-Data) */ text = dbi_result_get_string(result, "text"); if (text) -- To view, visit https://gerrit.osmocom.org/13489 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I75e852ebe44ba4784572cbffa029e13f0d3c430c Gerrit-Change-Number: 13489 Gerrit-PatchSet: 1 Gerrit-Owner: Vadim Yanitskiy