FreeRDP/FreeRDP — pull request #307 by absmall (2011-12-22 19:25:50+00:00)
Title: Fix crash when connecting using smartcard authentication

The fix is a little ugly with copy/paste sections, sorry, but without it, attrLen is being set sometimes even when a failure code is returned from libpcsc. The failure code appears to be correct, and the attrLen is bogus. Because of the non-zero attrLen, on the second retry, with an attrLen > 0, libpcsc (correctly) sets pbAttr, but to a non-NULL pointer (since it is not set for auto-allocate at this point). But if this buffer is too small (which it can conceivably be), then it can still return an error, now pbAttr is set to a bogus value too and rv shows a failure. Then the final code that checks for an error sees there is an error and attempts to free a bogus pbAttr causing a crash.

The problem appeared when I updated libpcsclite to debian version 1.8.1-4. I'm not sure what version I had before that, but whatever it was, this problem wasn't present with that version of libpcsclite.