mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
scd: Do not conflict if a card with another serialno is demanded.
* scd/app.c (check_application_conflict): Add args to pass a serialno. * scd/command.c (open_card_with_request): Pass the serialno to check_application_conflict. -- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
c8e62965bc
commit
92ba831758
3 changed files with 26 additions and 10 deletions
18
scd/app.c
18
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. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue