Change in ...osmo-msc[master]: db: Fix call to mempcy with NULL src ptr

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/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Jun 3 16:52:57 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/14355


Change subject: db: Fix call to mempcy with NULL src ptr
......................................................................

db: Fix call to mempcy with NULL src ptr

Catched by ASan on db_sms_test unit test:
DDB NOTICE test_db_sms_get('Empty TP-UD'): osmo-msc/src/libmsc/db.c:796:2: runtime error: null pointer passed as argument 2, which is declared to never be null

That happens on empty PDU because dbi_result_get_binary returns NULL,
and sms->user_data_len is 0, so it's harmless but we can avoid calling
mempcy and make ASan happy.

Change-Id: I545967464c406348b8505d1729213cfb4afcd3e2
---
M src/libmsc/db.c
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/55/14355/1

diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index add6304..e3995a6 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -793,7 +793,8 @@
 	user_data = dbi_result_get_binary(result, "user_data");
 	if (sms->user_data_len > sizeof(sms->user_data))
 		sms->user_data_len = (uint8_t) sizeof(sms->user_data);
-	memcpy(sms->user_data, user_data, sms->user_data_len);
+	if (user_data)
+		memcpy(sms->user_data, user_data, sms->user_data_len);
 
 	text = dbi_result_get_string(result, "text");
 	if (text)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/14355
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I545967464c406348b8505d1729213cfb4afcd3e2
Gerrit-Change-Number: 14355
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190603/bd4af6b7/attachment.htm>


More information about the gerrit-log mailing list