lynxis lazus has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-remsim/+/42200?usp=email )
Change subject: bankd: csv: fix crash on invalid lines
......................................................................
bankd: csv: fix crash on invalid lines
When no valid csv line is given (e.g. without any commas),
bankd will crash when trying to compile a regex with NULL.
Change-Id: Id6059c7dd4a119ffb1658a6cd7345a40bef3a69f
---
M src/bankd/bankd_pcsc.c
1 file changed, 10 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/00/42200/1
diff --git a/src/bankd/bankd_pcsc.c b/src/bankd/bankd_pcsc.c
index f9651f3..1804d01 100644
--- a/src/bankd/bankd_pcsc.c
+++ b/src/bankd/bankd_pcsc.c
@@ -101,13 +101,20 @@
LOGP(DMAIN, LOGL_INFO, "PC/SC slot name: %u/%u -> regex '%s'\n",
sn->slot.bank_id, sn->slot.slot_nr, sn->name_regex);
+ if (!sn->name_regex) {
+ LOGP(DMAIN, LOGL_ERROR, "B%d:%d: No reader name given. Maybe
invalid csv.\n",
+ sn->slot.bank_id, sn->slot.slot_nr);
+ talloc_free(sn);
+ goto out;
+ }
+
memset(&compiled_name, 0, sizeof(compiled_name));
rc = regcomp(&compiled_name, sn->name_regex, REG_EXTENDED);
if (rc != 0) {
char *errmsg = get_regerror(sn, rc, &compiled_name);
- LOGP(DMAIN, LOGL_ERROR, "Error compiling regex '%s': %s -
Ignoring\n",
- sn->name_regex, errmsg);
+ LOGP(DMAIN, LOGL_ERROR, "B%d:%d: Error compiling regex '%s': %s
- Ignoring\n",
+ sn->slot.bank_id, sn->slot.slot_nr, sn->name_regex,
errmsg);
talloc_free(errmsg);
talloc_free(sn);
} else {
@@ -115,6 +122,7 @@
}
regfree(&compiled_name);
+out:
ps->state = ST_BANK_NR;
ps->cur = NULL;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/42200?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: Id6059c7dd4a119ffb1658a6cd7345a40bef3a69f
Gerrit-Change-Number: 42200
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <[email protected]>