diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2015-12-09 15:27:09 +0100 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2015-12-10 11:39:36 +0100 |
commit | cb92eb444ab59953a28616ae96d250fa54a93d23 (patch) | |
tree | 5deb94e31e7dd478dacf803cd26eadb2ecde4651 /patches | |
parent | ccae755e4427051aed2dd1298af13bac633bc785 (diff) | |
download | ptxdist-cb92eb444ab59953a28616ae96d250fa54a93d23.tar.gz ptxdist-cb92eb444ab59953a28616ae96d250fa54a93d23.tar.xz |
openct: new package
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'patches')
-rw-r--r-- | patches/openct-0.6.20/0001-Handle-too-large-PC-SC-buffer-values.patch | 77 | ||||
-rw-r--r-- | patches/openct-0.6.20/series | 4 |
2 files changed, 81 insertions, 0 deletions
diff --git a/patches/openct-0.6.20/0001-Handle-too-large-PC-SC-buffer-values.patch b/patches/openct-0.6.20/0001-Handle-too-large-PC-SC-buffer-values.patch new file mode 100644 index 000000000..6e8ebe92f --- /dev/null +++ b/patches/openct-0.6.20/0001-Handle-too-large-PC-SC-buffer-values.patch @@ -0,0 +1,77 @@ +From: =?UTF-8?q?Marcin=20Cie=C5=9Blak?= <saper@saper.info> +Date: Sun, 15 Nov 2015 00:05:56 +0000 +Subject: [PATCH] Handle too large PC/SC buffer values + +pcsc-lite starting from 1.8.14 provides 65548 byte +receive buffers to IFDHTransmitToICC(), which is +a maximal extended APDU size. Unfortunately this +is more than CT API can use (16 bits). + +If more than 65536 bytes are about to be sent, +return IFD_PROTOCOL_NOT_SUPPORTED. + +Receive at most 65536 bytes. pcsc-lite will always +specify 65548 buffer, even if the client application +requests less; therefore we cannot return an error +in this case. + +Discussion: +https://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20151109/000493.html + +Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> +--- + src/pcsc/pcsc.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/src/pcsc/pcsc.c b/src/pcsc/pcsc.c +index 0ed9a619e53b..d769eb5625ec 100644 +--- a/src/pcsc/pcsc.c ++++ b/src/pcsc/pcsc.c +@@ -25,6 +25,7 @@ + #ifdef DEBUG_IFDH + #include <syslog.h> + #endif ++#include <limits.h> + #ifdef __APPLE__ + #include <PCSC/wintypes.h> + #include <PCSC/pcsclite.h> +@@ -390,6 +391,10 @@ IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci, + ctn = ((unsigned short)(Lun >> 16)) % IFDH_MAX_READERS; + slot = ((unsigned short)(Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; + ++ if (TxLength > USHRT_MAX) { ++ (*RxLength) = 0; ++ return IFD_PROTOCOL_NOT_SUPPORTED; ++ } + #ifdef HAVE_PTHREAD + pthread_mutex_lock(&ifdh_context_mutex[ctn]); + #endif +@@ -399,7 +404,7 @@ IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci, + #endif + dad = (UCHAR) ((slot == 0) ? 0x00 : slot + 1); + sad = 0x02; +- lr = (unsigned short)(*RxLength); ++ lr = (*RxLength > USHRT_MAX) ? USHRT_MAX : (unsigned short)(*RxLength); + lc = (unsigned short)TxLength; + + ret = CT_data(ctn, &dad, &sad, lc, TxBuffer, &lr, RxBuffer); +@@ -438,6 +443,10 @@ IFDHControl(DWORD Lun, PUCHAR TxBuffer, + ctn = ((unsigned short)(Lun >> 16)) % IFDH_MAX_READERS; + slot = ((unsigned short)(Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; + ++ if (TxLength > USHRT_MAX) { ++ (*RxLength) = 0; ++ return IFD_PROTOCOL_NOT_SUPPORTED; ++ } + #ifdef HAVE_PTHREAD + pthread_mutex_lock(&ifdh_context_mutex[ctn]); + #endif +@@ -447,7 +456,7 @@ IFDHControl(DWORD Lun, PUCHAR TxBuffer, + #endif + dad = 0x01; + sad = 0x02; +- lr = (unsigned short)(*RxLength); ++ lr = (*RxLength > USHRT_MAX) ? USHRT_MAX : (unsigned short)(*RxLength); + lc = (unsigned short)TxLength; + + ret = CT_data(ctn, &dad, &sad, lc, TxBuffer, &lr, RxBuffer); diff --git a/patches/openct-0.6.20/series b/patches/openct-0.6.20/series new file mode 100644 index 000000000..e1b5c45cf --- /dev/null +++ b/patches/openct-0.6.20/series @@ -0,0 +1,4 @@ +# generated by git-ptx-patches +#tag:base --start-number 1 +0001-Handle-too-large-PC-SC-buffer-values.patch +# 412ac4f5b443002e278d05ad793381f1 - git-ptx-patches magic |