Change in ...osmo-ccid-firmware[master]: ccid_slot_fsm: Avoid segfault on accessing slots 1..7

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.org
Thu Oct 10 13:01:28 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15752 )

Change subject: ccid_slot_fsm: Avoid segfault on accessing slots 1..7
......................................................................

ccid_slot_fsm: Avoid segfault on accessing slots 1..7

Change-Id: I3e3a20fad64ecbe3ccc50021da314901318b9c1d
---
M ccid_common/ccid_slot_fsm.c
1 file changed, 11 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index ce59474..59071de 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -166,11 +166,13 @@
 	struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
 	struct card_uart *cuart = talloc_zero(ctx, struct card_uart);
 	char id_buf[16];
-	char *devname = "/dev/null";
+	char *devname = NULL;
 	int rc;
 
 	LOGPCS(cs, LOGL_DEBUG, "%s\n", __func__);
 
+	/* HACK: make this in some way configurable so it works both in the firmware
+	 * and on the host (functionfs) */
 	if (cs->slot_nr == 0) {
 		cs->icc_present = true;
 		devname = "/dev/ttyUSB5";
@@ -180,13 +182,17 @@
 		return -ENOMEM;
 
 	snprintf(id_buf, sizeof(id_buf), "SIM%d", cs->slot_nr);
-	rc = card_uart_open(cuart, "tty", devname);
-	if (rc < 0) {
-		talloc_free(cuart);
-		return rc;
+	if (devname) {
+		rc = card_uart_open(cuart, "tty", devname);
+		if (rc < 0) {
+			LOGPCS(cs, LOGL_ERROR, "Cannot open UART %s: %d\n", devname, rc);
+			talloc_free(cuart);
+			return rc;
+		}
 	}
 	ss->fi = iso7816_fsm_alloc(ctx, LOGL_DEBUG, id_buf, cuart, iso_fsm_clot_user_cb, ss);
 	if (!ss->fi) {
+		LOGPCS(cs, LOGL_ERROR, "Cannot allocate ISO FSM\n");
 		talloc_free(cuart);
 		return -1;
 	}

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

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I3e3a20fad64ecbe3ccc50021da314901318b9c1d
Gerrit-Change-Number: 15752
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191010/2f6a6fbf/attachment.htm>


More information about the gerrit-log mailing list