21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

typedef struct {<br />

LPTSTR lpszAddress;<br />

LPSTR lpszID;<br />

LARGE_INTEGER liExpire;<br />

} SPC_CONFIRMATION;<br />

static DWORD dwConfirmationCount, dwConfirmationSize;<br />

static SPC_CONFIRMATION *pConfirmations;<br />

static BOOL NewConfirmation(LPCTSTR lpszAddress, LPCSTR lpszID) {<br />

DWORD dwIndex;<br />

LARGE_INTEGER liExpire;<br />

SPC_CONFIRMATION *pTemp;<br />

/* first make sure that the address isn't already in the list */<br />

for (dwIndex = 0; dwIndex < dwConfirmationCount; dwIndex++) {<br />

if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE,<br />

pConfirmations[dwIndex].lpszAddress, -1,<br />

lpszAddress, -1) = = CSTR_EQUAL) return FALSE;<br />

}<br />

if (dwConfirmationCount = = dwConfirmationSize) {<br />

if (!pConfirmations)<br />

pTemp = (SPC_CONFIRMATION *)LocalAlloc(LMEM_FIXED, sizeof(SPC_CONFIRMATION));<br />

else<br />

pTemp = (SPC_CONFIRMATION *)LocalReAlloc(pConfirmations,<br />

sizeof(SPC_CONFIRMATION) * (dwConfirmationSize + 1), 0);<br />

if (!pTemp) return FALSE;<br />

pConfirmations = pTemp;<br />

dwConfirmationSize++;<br />

}<br />

pConfirmations[dwConfirmationCount].lpszAddress = (LPTSTR)LocalAlloc(<br />

LMEM_FIXED, sizeof(TCHAR) * (lstrlen(lpszAddress) + 1));<br />

if (!pConfirmations[dwConfirmationCount].lpszAddress) return FALSE;<br />

lstrcpy(pConfirmations[dwConfirmationCount].lpszAddress, lpszAddress);<br />

pConfirmations[dwConfirmationCount].lpszID = (LPSTR)LocalAlloc(LMEM_FIXED,<br />

lstrlenA(lpszID) + 1);<br />

if (!pConfirmations[dwConfirmationCount].lpszID) {<br />

LocalFree(pConfirmations[dwConfirmationCount].lpszAddress);<br />

return FALSE;<br />

}<br />

lstrcpyA(pConfirmations[dwConfirmationCount].lpszID, lpszID);<br />

/* File Times are 100-nanosecond intervals since January 1, 1601 */<br />

GetSystemTimeAsFileTime((LPFILETIME)&liExpire);<br />

liExpire.QuadPart += (SPC_CONFIRMATION_EXPIRE * (__int64)10000000);<br />

pConfirmations[dwConfirmationCount].liExpire = liExpire;<br />

dwConfirmationCount++;<br />

return TRUE;<br />

}<br />

452 | Chapter 8: Authentication and Key Exchange<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!