aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'scd/app.c')
-rw-r--r--scd/app.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/scd/app.c b/scd/app.c
index 1ad6b9ed6..ed7adc3a3 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -260,10 +260,15 @@ is_app_allowed (const char *name)
* 0 - No conflict
* GPG_ERR_FALSE - Another application is in use but it is possible
* to switch to the requested application.
- * other code - Switching is not possible.
+ * Other code - Switching is not possible.
+ *
+ * If SERIALNO_BIN is not NULL a coflict is onl asserted if the
+ * serialno of the card matches.
*/
gpg_error_t
-check_application_conflict (card_t card, const char *name)
+check_application_conflict (card_t card, const char *name,
+ const unsigned char *serialno_bin,
+ size_t serialno_bin_len)
{
app_t app;
@@ -272,6 +277,13 @@ check_application_conflict (card_t card, const char *name)
if (!card->app)
return gpg_error (GPG_ERR_CARD_NOT_INITIALIZED); /* Should not happen. */
+ if (serialno_bin && card->serialno)
+ {
+ if (serialno_bin_len != card->serialnolen
+ || memcmp (serialno_bin, card->serialno, card->serialnolen))
+ return 0; /* The card does not match the requested S/N. */
+ }
+
/* Check whether the requested NAME matches any already selected
* application. */
for (app = card->app; app; app = app->next)
@@ -638,7 +650,7 @@ select_application (ctrl_t ctrl, const char *name, card_t *r_card,
if (card)
{
- err = check_application_conflict (card, name);
+ err = check_application_conflict (card, name, NULL, 0);
if (!err)
{
/* Note: We do not use card_ref as we are already locked. */