diff options
author | Diego Elio Pettenò <flameeyes@gentoo.org> | 2010-12-26 17:28:31 +0000 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@gentoo.org> | 2010-12-26 17:28:31 +0000 |
commit | f03320408e516984fee4fcb89f86a19ed157bda8 (patch) | |
tree | 45e02fd044d7427de7896ae5f9d55d8d95bb7b15 /dev-libs/opensc/files | |
parent | Added ~mips, bug 263337 (diff) | |
download | historical-f03320408e516984fee4fcb89f86a19ed157bda8.tar.gz historical-f03320408e516984fee4fcb89f86a19ed157bda8.tar.bz2 historical-f03320408e516984fee4fcb89f86a19ed157bda8.zip |
Add patch to fix possible buffer overflows; thanks to Tim Sammut (underling) for reporting in bug #349567.
Package-Manager: portage-2.2.0_alpha10/cvs/Linux x86_64
Diffstat (limited to 'dev-libs/opensc/files')
-rw-r--r-- | dev-libs/opensc/files/opensc-0.11.13-overflows.patch | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dev-libs/opensc/files/opensc-0.11.13-overflows.patch b/dev-libs/opensc/files/opensc-0.11.13-overflows.patch new file mode 100644 index 000000000000..3b83e2d45f37 --- /dev/null +++ b/dev-libs/opensc/files/opensc-0.11.13-overflows.patch @@ -0,0 +1,71 @@ +--- a/src/libopensc/internal.h ++++ b/src/libopensc/internal.h +@@ -49,6 +49,13 @@ extern "C" { + #define sleep(t) Sleep((t) * 1000) + #endif + ++#ifndef MAX ++#define MAX(x, y) (((x) > (y)) ? (x) : (y)) ++#endif ++#ifndef MIN ++#define MIN(x, y) (((x) < (y)) ? (x) : (y)) ++#endif ++ + struct sc_atr_table { + /* The atr fields are required to + * be in aa:bb:cc hex format. */ +--- a/src/libopensc/muscle.c ++++ b/src/libopensc/muscle.c +@@ -31,13 +31,6 @@ + #define MSC_DSA_PUBLIC 0x04 + #define MSC_DSA_PRIVATE 0x05 + +-#ifndef MAX +-#define MAX(x, y) (((x) > (y)) ? (x) : (y)) +-#endif +-#ifndef MIN +-#define MIN(x, y) (((x) < (y)) ? (x) : (y)) +-#endif +- + static msc_id inputId = { { 0xFF, 0xFF, 0xFF, 0xFF } }; + static msc_id outputId = { { 0xFF, 0xFF, 0xFF, 0xFE } }; + +--- a/src/libopensc/card-acos5.c ++++ b/src/libopensc/card-acos5.c +@@ -138,8 +138,8 @@ static int acos5_get_serialnr(sc_card_t * card, sc_serial_number_t * serial) + /* + * Cache serial number. + */ +- memcpy(card->serialnr.value, apdu.resp, apdu.resplen); +- card->serialnr.len = apdu.resplen; ++ memcpy(card->serialnr.value, apdu.resp, MIN(apdu.resplen, SC_MAX_SERIALNR)); ++ card->serialnr.len = MIN(apdu.resplen, SC_MAX_SERIALNR); + + /* + * Copy and return serial number. +--- a/src/libopensc/card-atrust-acos.c ++++ b/src/libopensc/card-atrust-acos.c +@@ -842,8 +842,8 @@ static int acos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) + if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00) + return SC_ERROR_INTERNAL; + /* cache serial number */ +- memcpy(card->serialnr.value, apdu.resp, apdu.resplen); +- card->serialnr.len = apdu.resplen; ++ memcpy(card->serialnr.value, apdu.resp, MIN(apdu.resplen, SC_MAX_SERIALNR)); ++ card->serialnr.len = MIN(apdu.resplen, SC_MAX_SERIALNR); + /* copy and return serial number */ + memcpy(serial, &card->serialnr, sizeof(*serial)); + return SC_SUCCESS; +--- a/src/libopensc/card-starcos.c ++++ b/src/libopensc/card-starcos.c +@@ -1279,8 +1279,8 @@ static int starcos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) + if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00) + return SC_ERROR_INTERNAL; + /* cache serial number */ +- memcpy(card->serialnr.value, apdu.resp, apdu.resplen); +- card->serialnr.len = apdu.resplen; ++ memcpy(card->serialnr.value, apdu.resp, MIN(apdu.resplen, SC_MAX_SERIALNR)); ++ card->serialnr.len = MIN(apdu.resplen, SC_MAX_SERIALNR); + /* copy and return serial number */ + memcpy(serial, &card->serialnr, sizeof(*serial)); + return SC_SUCCESS; |