Skip to content

Commit 103c622

Browse files
Robert GolebiowskiHery Ramilison
authored andcommitted
Bug #24512715 AUTH_SEC.MYSQL_SSL_RSA_SETUP FAILS CONSISTENTLY ON HUDSON
Fix provided by YASSL. Upgrading YASSL to version 2.4.0. (cherry picked from commit 840ca33cf4f61677c125a86b0b09aef6db3578bc)
1 parent aa1ecf2 commit 103c622

File tree

5 files changed

+56
-17
lines changed

5 files changed

+56
-17
lines changed

extra/yassl/README

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ before calling SSL_new();
1212

1313
*** end Note ***
1414

15+
yaSSL Release notes, version 2.4.0 (5/20/2016)
16+
This release of yaSSL fixes the OpenSSL compatibility function
17+
SSL_CTX_load_verify_locations() when using the path directory to allow
18+
unlimited path sizes. Minor Windows build fixes are included.
19+
No high level security fixes in this version but we always recommend
20+
updating.
21+
22+
1523
yaSSL Release notes, version 2.3.9b (2/03/2016)
1624
This release of yaSSL fixes the OpenSSL compatibility function
1725
X509_NAME_get_index_by_NID() to use the actual index of the common name

extra/yassl/include/openssl/ssl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "rsa.h"
3535

3636

37-
#define YASSL_VERSION "2.3.9b"
37+
#define YASSL_VERSION "2.4.0"
3838

3939

4040
#if defined(__cplusplus)

extra/yassl/src/ssl.cpp

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -849,40 +849,67 @@ int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file,
849849
WIN32_FIND_DATA FindFileData;
850850
HANDLE hFind;
851851

852-
char name[MAX_PATH + 1]; // directory specification
853-
strncpy(name, path, MAX_PATH - 3);
854-
strncat(name, "\\*", 3);
852+
const int DELIMITER_SZ = 2;
853+
const int DELIMITER_STAR_SZ = 3;
854+
int pathSz = (int)strlen(path);
855+
int nameSz = pathSz + DELIMITER_STAR_SZ + 1; // plus 1 for terminator
856+
char* name = NEW_YS char[nameSz]; // directory specification
857+
memset(name, 0, nameSz);
858+
strncpy(name, path, nameSz - DELIMITER_STAR_SZ - 1);
859+
strncat(name, "\\*", DELIMITER_STAR_SZ);
855860

856861
hFind = FindFirstFile(name, &FindFileData);
857-
if (hFind == INVALID_HANDLE_VALUE) return SSL_BAD_PATH;
862+
if (hFind == INVALID_HANDLE_VALUE) {
863+
ysArrayDelete(name);
864+
return SSL_BAD_PATH;
865+
}
858866

859867
do {
860-
if (FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) {
861-
strncpy(name, path, MAX_PATH - 2 - HALF_PATH);
862-
strncat(name, "\\", 2);
863-
strncat(name, FindFileData.cFileName, HALF_PATH);
868+
if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
869+
int curSz = (int)strlen(FindFileData.cFileName);
870+
if (pathSz + curSz + DELIMITER_SZ + 1 > nameSz) {
871+
ysArrayDelete(name);
872+
// plus 1 for terminator
873+
nameSz = pathSz + curSz + DELIMITER_SZ + 1;
874+
name = NEW_YS char[nameSz];
875+
}
876+
memset(name, 0, nameSz);
877+
strncpy(name, path, nameSz - curSz - DELIMITER_SZ - 1);
878+
strncat(name, "\\", DELIMITER_SZ);
879+
strncat(name, FindFileData.cFileName,
880+
nameSz - pathSz - DELIMITER_SZ - 1);
864881
ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);
865882
}
866883
} while (ret == SSL_SUCCESS && FindNextFile(hFind, &FindFileData));
867884

885+
ysArrayDelete(name);
868886
FindClose(hFind);
869887

870888
#else // _WIN32
871-
872-
const int MAX_PATH = 260;
873-
874889
DIR* dir = opendir(path);
875890
if (!dir) return SSL_BAD_PATH;
876891

877892
struct dirent* entry;
878893
struct stat buf;
879-
char name[MAX_PATH + 1];
894+
const int DELIMITER_SZ = 1;
895+
int pathSz = (int)strlen(path);
896+
int nameSz = pathSz + DELIMITER_SZ + 1; //plus 1 for null terminator
897+
char* name = NEW_YS char[nameSz]; // directory specification
880898

881899
while (ret == SSL_SUCCESS && (entry = readdir(dir))) {
882-
strncpy(name, path, MAX_PATH - 1 - HALF_PATH);
883-
strncat(name, "/", 1);
884-
strncat(name, entry->d_name, HALF_PATH);
900+
int curSz = (int)strlen(entry->d_name);
901+
if (pathSz + curSz + DELIMITER_SZ + 1 > nameSz) {
902+
ysArrayDelete(name);
903+
nameSz = pathSz + DELIMITER_SZ + curSz + 1;
904+
name = NEW_YS char[nameSz];
905+
}
906+
memset(name, 0, nameSz);
907+
strncpy(name, path, nameSz - curSz - 1);
908+
strncat(name, "/", DELIMITER_SZ);
909+
strncat(name, entry->d_name, nameSz - pathSz - DELIMITER_SZ - 1);
910+
885911
if (stat(name, &buf) < 0) {
912+
ysArrayDelete(name);
886913
closedir(dir);
887914
return SSL_BAD_STAT;
888915
}
@@ -891,6 +918,7 @@ int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file,
891918
ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);
892919
}
893920

921+
ysArrayDelete(name);
894922
closedir(dir);
895923

896924
#endif

extra/yassl/taocrypt/include/integer.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ namespace TaoCrypt {
119119

120120

121121

122+
#ifdef _WIN32
123+
#undef max // avoid name clash
124+
#endif
122125
// general MAX
123126
template<typename T> inline
124127
const T& max(const T& a, const T& b)

extra/yassl/testsuite/test.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#define yaSSL_TEST_HPP
2323

2424
#include "runtime.hpp"
25-
#include "openssl/ssl.h" /* openssl compatibility test */
2625
#include "error.hpp"
2726
#include <stdio.h>
2827
#include <stdlib.h>
@@ -56,6 +55,7 @@
5655
#endif
5756
#define SOCKET_T int
5857
#endif /* _WIN32 */
58+
#include "openssl/ssl.h" /* openssl compatibility test */
5959

6060

6161
#ifdef _MSC_VER

0 commit comments

Comments
 (0)