Your message dated Sat, 27 May 2023 05:04:42 +0000
with message-id <e1q2m6c-00buwd...@fasolo.debian.org>
and subject line Bug#1036318: Removed package(s) from unstable
has caused the Debian Bug report #903940,
regarding Integer overflow on buffer sizes causes complete failure of driver
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
903940: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903940
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Package: libtowitoko2
Version: 2.0.7-9
Severity: grave
Tags: patch

pcscd nowadays passes in buffers much larger than can be represented in an
unsigned short when communicating with the card reader, but libtowitoko2
simply casts the length to an unsigned short, which leads to
overflow/truncation of the buffer size and thus to complete failure to use
the Towitoko reader using this driver.

The attached patch simply limits the buffer sizes that are passed into the
driver to what can be represented in unsigned shorts, which makes it all
work again for me.
diff --git a/src/ifd-handler/ifdhandler.c b/src/ifd-handler/ifdhandler.c
index 5fc0299..b3dbcaa 100644
--- a/src/ifd-handler/ifdhandler.c
+++ b/src/ifd-handler/ifdhandler.c
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <limits.h>
 #ifdef HAVE_PTHREAD_H
 #include <pthread.h>
 #endif
@@ -497,15 +498,24 @@ IFDHTransmitToICC (DWORD Lun, SCARD_IO_HEADER SendPci,
 #endif
       dad = (UCHAR) ((slot == 0) ? 0x00 : slot + 1);
       sad = 0x02;
-      lr = (unsigned short) (*RxLength);
-      lc = (unsigned short) TxLength;
-
-      ret = CT_data (ctn, &dad, &sad, lc, TxBuffer, &lr, RxBuffer);
-
-      if (ret == OK)
+      lr = ((*RxLength) > USHRT_MAX) ? USHRT_MAX : ((unsigned short) (*RxLength));
+      if (TxLength <= USHRT_MAX)
         {
-          (*RxLength) = lr;
-          rv = IFD_SUCCESS;
+          lc = (unsigned short) TxLength;
+    
+          ret = CT_data (ctn, &dad, &sad, lc, TxBuffer, &lr, RxBuffer);
+    
+          if (ret == OK)
+            {
+              (*RxLength) = lr;
+              rv = IFD_SUCCESS;
+            }
+    
+          else
+            {
+              (*RxLength) = 0;
+              rv = IFD_COMMUNICATION_ERROR;
+            }
         }
 
       else

--- End Message ---
--- Begin Message ---
Version: 2.0.7-9+rm

Dear submitter,

as the package towitoko has just been removed from the Debian archive
unstable we hereby close the associated bug reports.  We are sorry
that we couldn't deal with your issue properly.

For details on the removal, please see https://bugs.debian.org/1036318

The version of this package that was in Debian prior to this removal
can still be found using https://snapshot.debian.org/.

Please note that the changes have been done on the master archive and
will not propagate to any mirrors until the next dinstall run at the
earliest.

This message was generated automatically; if you believe that there is
a problem with it please contact the archive administrators by mailing
ftpmas...@ftp-master.debian.org.

Debian distribution maintenance software
pp.
Scott Kitterman (the ftpmaster behind the curtain)

--- End Message ---

Reply via email to