cac1: Correctly handle the buffer limits
cac1: Correctly handle the buffer limits

Found by oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18618
and others

mouse07410/OpenSC,LudovicRousseau/OpenSC,AktivCo/OpenSC,frankmorgner/OpenSC,philipWendland/OpenSC,LudovicRousseau/OpenSC,hongquan/OpenSC-main,hongquan/OpenSC-main,CardContact/OpenSC,AktivCo/OpenSC,Jakuje/OpenSC,frankmorgner/OpenSC,metsma/OpenSC,dengert/OpenSC,mouse07410/OpenSC,LudovicRousseau/OpenSC,philipWendland/OpenSC,metsma/OpenSC,dengert/OpenSC,Jakuje/OpenSC,philipWendland/OpenSC,fabled/OpenSC,metsma/OpenSC,frankmorgner/OpenSC,CardContact/OpenSC,rickyepoderi/OpenSC,fabled/OpenSC,OpenSC/OpenSC,fabled/OpenSC,fabled/OpenSC,CardContact/OpenSC,OpenSC/OpenSC,mouse07410/OpenSC,rickyepoderi/OpenSC,Jakuje/OpenSC,rickyepoderi/OpenSC,Jakuje/OpenSC,OpenSC/OpenSC,dengert/OpenSC,AktivCo/OpenSC,frankmorgner/OpenSC,hongquan/OpenSC-main