liburcu: Update to 0.8.6
[feed/packages.git] / utils / opensc / patches / 0016-OpenPGP-Correct-parameter-checking.patch
1 From f96f7536a8c2efd0ba41fd94fe3334e5fa556854 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/18] OpenPGP: Correct parameter checking.
6
7 ---
8 src/libopensc/card-openpgp.c | 9 +++++++--
9 1 file changed, 7 insertions(+), 2 deletions(-)
10
11 diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
12 index 19d3b04..196c094 100644
13 --- a/src/libopensc/card-openpgp.c
14 +++ b/src/libopensc/card-openpgp.c
15 @@ -1221,6 +1221,8 @@ static int gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length)
16 LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
17 /* Check response */
18 r = sc_check_sw(card, apdu.sw1, apdu.sw2);
19 + if (r < 0)
20 + LOG_FUNC_RETURN(card->ctx, r);
21 LOG_FUNC_RETURN(card->ctx, length);
22 }
23
24 @@ -2448,6 +2450,11 @@ gnuk_delete_key(sc_card_t *card, u8 key_id)
25
26 LOG_FUNC_CALLED(ctx);
27
28 + if (key_id < 1 || key_id > 3) {
29 + sc_log(ctx, "Key ID %d is invalid. Should be 1, 2 or 3.", key_id);
30 + LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
31 + }
32 +
33 /* Delete fingerprint */
34 sc_log(ctx, "Delete fingerprints");
35 r = pgp_put_data(card, 0xC6 + key_id, NULL, 0);
36 @@ -2466,8 +2473,6 @@ gnuk_delete_key(sc_card_t *card, u8 key_id)
37 data = "\x4D\x02\xB8";
38 else if (key_id == 3)
39 data = "\x4D\x02\xA4";
40 - else
41 - LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
42
43 r = pgp_put_data(card, 0x4D, data, strlen(data) + 1);
44
45 --
46 1.9.3
47