diff --git a/ChangeLog b/ChangeLog index e9e9cd2fe..dc68f04c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ PolarSSL ChangeLog += Version Trunk +Bugfixes + * Fixes for MSVC6 + = Version 1.2.0 released 2012-10-31 Features * Added support for NULL cipher (POLARSSL_CIPHER_NULL_CIPHER) and weak diff --git a/include/polarssl/bignum.h b/include/polarssl/bignum.h index e2d93476d..3b8b1f613 100644 --- a/include/polarssl/bignum.h +++ b/include/polarssl/bignum.h @@ -34,8 +34,13 @@ #ifdef _MSC_VER #include +#if (_MSC_VER <= 1200) +typedef signed short int16_t; +typedef unsigned short uint16_t; +#else typedef INT16 int16_t; typedef UINT16 uint16_t; +#endif typedef INT32 int32_t; typedef UINT32 uint32_t; typedef UINT64 uint64_t; diff --git a/include/polarssl/gcm.h b/include/polarssl/gcm.h index 2f88c7015..77baa1756 100644 --- a/include/polarssl/gcm.h +++ b/include/polarssl/gcm.h @@ -29,7 +29,12 @@ #include "aes.h" +#ifdef _MSC_VER +#include +typedef UINT64 uint64_t; +#else #include +#endif #define GCM_ENCRYPT 1 #define GCM_DECRYPT 0 diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h index c7da8c4d5..071288e92 100644 --- a/include/polarssl/ssl.h +++ b/include/polarssl/ssl.h @@ -682,7 +682,7 @@ void ssl_set_bio( ssl_context *ssl, * data) is cleared by the SSL/TLS layer when the connection is * terminated. It is recommended to add metadata to determine if * an entry is still valid in the future. Return 0 if - * successfully cached, return 0 otherwise. + * successfully cached, return 1 otherwise. * * \param ssl SSL context * \param f_get_cache session get callback diff --git a/library/entropy_poll.c b/library/entropy_poll.c index a0c9b7bc0..b5d9f787c 100644 --- a/library/entropy_poll.c +++ b/library/entropy_poll.c @@ -40,10 +40,10 @@ #if !defined(POLARSSL_NO_PLATFORM_ENTROPY) #if defined(_WIN32) -#include #if !defined(_WIN32_WINNT) #define _WIN32_WINNT 0x0400 #endif +#include #include int platform_entropy_poll( void *data, unsigned char *output, size_t len, diff --git a/library/gcm.c b/library/gcm.c index 3faaa5d89..c91598cd2 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -148,7 +148,7 @@ void gcm_mult( gcm_context *ctx, const unsigned char x[16], unsigned char output if( i != 15 ) { - rem = zl & 0xf; + rem = (unsigned char) zl & 0xf; zl = ( zh << 60 ) | ( zl >> 4 ); zh = ( zh >> 4 ); zh ^= (uint64_t) last4[rem] << 48; @@ -157,7 +157,7 @@ void gcm_mult( gcm_context *ctx, const unsigned char x[16], unsigned char output } - rem = zl & 0xf; + rem = (unsigned char) zl & 0xf; zl = ( zh << 60 ) | ( zl >> 4 ); zh = ( zh >> 4 ); zh ^= (uint64_t) last4[rem] << 48; diff --git a/library/x509parse.c b/library/x509parse.c index ab633be99..843dba7f5 100644 --- a/library/x509parse.c +++ b/library/x509parse.c @@ -60,9 +60,7 @@ #if defined(POLARSSL_FS_IO) #include -#if defined(_WIN32) -#include -#else +#if !defined(_WIN32) #include #include #endif @@ -1878,50 +1876,55 @@ int x509parse_crtpath( x509_cert *chain, const char *path ) WCHAR szDir[MAX_PATH]; char filename[MAX_PATH]; char *p; + int len = strlen( path ); WIN32_FIND_DATA file_data; HANDLE hFind; - DWORD dwError = 0; + + if( len > MAX_PATH - 3 ) + return( POLARSSL_ERR_X509_INVALID_INPUT ); memset( szDir, 0, sizeof(szDir) ); memset( filename, 0, MAX_PATH ); - memcpy( filename, path, strlen( path ) ); - filename[strlen( path )] = '\\'; - p = filename + strlen( path ) + 1; + memcpy( filename, path, len ); + filename[len++] = '\\'; + p = filename + len; + filename[len++] = '*'; - w_ret = MultiByteToWideChar( CP_ACP, 0, path, strlen(path), szDir, MAX_PATH - 3 ); - - StringCchCopyW(szDir, MAX_PATH, szDir); - StringCchCatW(szDir, MAX_PATH, TEXT("\\*")); + w_ret = MultiByteToWideChar( CP_ACP, 0, path, len, szDir, MAX_PATH - 3 ); hFind = FindFirstFile( szDir, &file_data ); if (hFind == INVALID_HANDLE_VALUE) return( POLARSSL_ERR_X509_FILE_IO_ERROR ); + len = MAX_PATH - len; do { - memset( p, 0, filename + MAX_PATH - p - 1 ); + memset( p, 0, len ); if( file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) continue; w_ret = WideCharToMultiByte( CP_ACP, 0, file_data.cFileName, lstrlenW(file_data.cFileName), - p, - filename + MAX_PATH - p - 2, NULL, NULL ); + p, len - 1, + NULL, NULL ); w_ret = x509parse_crtfile( chain, filename ); if( w_ret < 0 ) - return( w_ret ); + { + ret = w_ret; + goto cleanup; + } ret += w_ret; } while( FindNextFile( hFind, &file_data ) != 0 ); - dwError = GetLastError(); - if (dwError != ERROR_NO_MORE_FILES) - return( POLARSSL_ERR_X509_FILE_IO_ERROR ); + if (GetLastError() != ERROR_NO_MORE_FILES) + ret = POLARSSL_ERR_X509_FILE_IO_ERROR; +cleanup: FindClose( hFind ); #else int t_ret;