Hi all

I encountered a severe problem with the current CT-API interface used in
MUSCLE. The skeleton defines the interface to be

int CT_init(unsigned int Ctn, unsigned int pn)
int CT_data(unsigned int ctn, unsigned char *dad, unsigned char *sad,
                 unsigned int lc, unsigned char *cmd, unsigned int *lr,
             unsigned char *rsp)
and
int CT_close(unsigned int Ctn)

whereas the original CT-API specification defines

char CT_init(unsigned short Ctn, unsigned short pn)
char CT_data(unsigned short ctn, unsigned char *dad, unsigned char *sad,
                    unsigned short lc, unsigned char *cmd, unsigned short *lr,
                unsigned char *rsp) 
and
char CT_close(unsigned int Ctn)

Most of the type conversions are handled automatically by the compiler, but the
problem comes up with the lr parameter in CT_data. Usually the compiler will
warn about the size conflict if the program declares a variable

unsigned short rlen;

CT_data(......, &rlen,...)

but if it goes undetected it may have severe results, because it overwrites
data objects on the stack located beside the rlen variable (As happend in my
case and which cause a fairly long debugging session).

I know that this is an ugly problem, but I would still recommend to change the
interface declaration to archive cross platform compatibility and avoid hard to
find errors as the one above.

Any comments ?

--
Andreas Schwier     Tel. +49 171 8334920
CardContact Software & System Consulting
http://www.cardcontact.de
***************************************************************
Linux Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/smartcard/index.html
***************************************************************

Reply via email to