You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.5 KiB

  1. From ee23d262768e7e54ed0fc554bc0b869c65868ace Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?=
  3. <ng.hong.quan@gmail.com>
  4. Date: Tue, 16 Apr 2013 10:19:34 +0700
  5. Subject: [PATCH 16/26] OpenPGP: Correct parameter checking.
  6. ---
  7. src/libopensc/card-openpgp.c | 9 +++++++--
  8. 1 file changed, 7 insertions(+), 2 deletions(-)
  9. diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
  10. index 4d0500d..beeee83 100644
  11. --- a/src/libopensc/card-openpgp.c
  12. +++ b/src/libopensc/card-openpgp.c
  13. @@ -1223,6 +1223,8 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
  14. LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  15. /* Check response */
  16. r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  17. + if (r < 0)
  18. + LOG_FUNC_RETURN(card->ctx, r);
  19. LOG_FUNC_RETURN(card->ctx, length);
  20. }
  21. @@ -2446,6 +2448,11 @@ gnuk_delete_key(sc_card_t *card, u8 key_id)
  22. LOG_FUNC_CALLED(ctx);
  23. + if (key_id < 1 || key_id > 3) {
  24. + sc_log(ctx, "Key ID %d is invalid. Should be 1, 2 or 3.", key_id);
  25. + LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  26. + }
  27. +
  28. /* Delete fingerprint */
  29. sc_log(ctx, "Delete fingerprints");
  30. r = pgp_put_data(card, 0xC6 + key_id, NULL, 0);
  31. @@ -2464,8 +2471,6 @@ gnuk_delete_key(sc_card_t *card, u8 key_id)
  32. data = "\x4D\x02\xB8";
  33. else if (key_id == 3)
  34. data = "\x4D\x02\xA4";
  35. - else
  36. - LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  37. r = pgp_put_data(card, 0x4D, data, strlen(data) + 1);
  38. --
  39. 2.1.3