Skip to content

Commit

Permalink
SQLyog 13.1.4 GA
Browse files Browse the repository at this point in the history
  • Loading branch information
wydeep committed Jun 29, 2019
1 parent 16fe6de commit 4204685
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 38 deletions.
2 changes: 1 addition & 1 deletion include/CommonHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

#define FMT_SPACE_4 " "

#define REGKEY "Use any UUID here"
#define REGKEY "xxx" //Provide any UUID here


#define SSHTUNNELER "plink.exe"
Expand Down
2 changes: 1 addition & 1 deletion include/Version.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define MAJOR_VERSION_INT 13
#define MINOR_VERSION_INT 1
#define UPDATE_VERSION_INT 3
#define UPDATE_VERSION_INT 4
#define RELEASE_VERSION_INT 0
#define EXTRAINFO " "
3 changes: 3 additions & 0 deletions include/wyString.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ class wyString
void JsonEscape();
void JsonEscapeForEncryptPassword();
static void JsonDeEscapeForEncryptPassword(wyString &pwstr);
static void DecodeBase64Password(wyString &pwstr);
wyChar* EncodeBase64Password();
void EscapeNullFromPassword();
private:

/// Actual data container.
Expand Down
22 changes: 16 additions & 6 deletions src/CommonHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ extern FILE *logfilehandle;
static wyChar table64[]=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

static CryptoPP::byte AESKey[16] = { 0 }; //Provide any IV
static CryptoPP::byte AESiv[16] = { 0 }; //Provide any key
static CryptoPP::byte AESKey[16] = { };// Type any key
static CryptoPP::byte AESiv[16] = { };//Type any IV

Tunnel *
CreateTunnel(wyBool istunnel)
Expand Down Expand Up @@ -4608,7 +4608,7 @@ EncodePassword(wyString &text)
//encryption
encFilter.Put(reinterpret_cast<const CryptoPP::byte*>(plaintext.GetString()), plaintext.GetLength());
encFilter.MessageEnd();
text.SetAs(encText.data(), encText.length());
text.SetAsDirect(encText.data(), encText.length());

return wyTrue;
}
Expand All @@ -4623,7 +4623,7 @@ DecodePassword(wyString &text)
return wyFalse;
}

ciphertext.SetAs(text);
ciphertext.SetAsDirect(text.GetString(), text.GetLength());

CryptoPP::CTR_Mode<CryptoPP::AES>::Decryption dec;
dec.SetKeyWithIV(AESKey, sizeof(AESKey), AESiv);
Expand All @@ -4645,7 +4645,12 @@ MigratePassword(wyString conn, wyString dirstr, wyString &pwdstr)

DecodePassword_Absolute(pwdstr);
EncodePassword(pwdstr);
pwdstr.JsonEscapeForEncryptPassword();
wyChar *encodestr=pwdstr.EncodeBase64Password();
pwdstr.Clear();
pwdstr.SetAs(encodestr);

if (encodestr)
free(encodestr);
return wyTrue;

}
Expand All @@ -4656,7 +4661,12 @@ MigratePassword(wyString &pwdstr)

DecodePassword_Absolute(pwdstr);
EncodePassword(pwdstr);
pwdstr.JsonEscapeForEncryptPassword();
wyChar *encodestr=pwdstr.EncodeBase64Password();
pwdstr.Clear();
pwdstr.SetAs(encodestr);

if (encodestr)
free(encodestr);
return wyTrue;

}
36 changes: 25 additions & 11 deletions src/ConnectionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1655,9 +1655,16 @@ ConnectionBase::GetInitialDetails(HWND hdlg)

strcpy(pwd, pwdstr.GetString());

//pwdstr.FindAndReplace("\\n", "\n");
wyString::JsonDeEscapeForEncryptPassword(pwdstr);

/*wyChar *decodedstr = NULL;
decodedstr = AllocateBuff(512);
wyInt32 len = DecodeBase64(pwdstr.GetString(), decodedstr);
pwdstr.SetAsDirect(decodedstr, len);*/
wyString::DecodeBase64Password(pwdstr);
DecodePassword(pwdstr);

/*if (decodedstr)
free(decodedstr);*/

ret = wyIni::IniGetString(conn.GetString(), "User", "root", &userstr, dirstr.GetString());
ret = wyIni::IniGetString(conn.GetString(), "Host", "localhost", &hoststr, dirstr.GetString());
ret = wyIni::IniGetString(conn.GetString(), "Port", "3306", &portstr, dirstr.GetString());
Expand All @@ -1668,8 +1675,6 @@ ConnectionBase::GetInitialDetails(HWND hdlg)
storepwd = wyIni::IniGetInt(conn.GetString(), "StorePassword", 1, dirstr.GetString());
Button_SetCheck(GetDlgItem(hdlg, IDC_DLGCONNECT_STOREPASSWORD), storepwd);

DecodePassword(pwdstr);

//Compressed prtocol
usecompress = wyIni::IniGetInt(conn.GetString(), "compressedprotocol", 1, dirstr.GetString());
Button_SetCheck(GetDlgItem(hdlg, IDC_COMPRESS), usecompress);
Expand Down Expand Up @@ -1743,14 +1748,15 @@ ConnectionBase::GetInitialDetails(HWND hdlg)
/* now it may happen that without saving anything the user has connected
so the field will be removed and the next time he wont get anything
to handle such cases we have to by default write the encodedpassword */
wyChar* encodestr = NULL;
if(!decodepwd)
{
pwdstr.SetAs(pwd);
EncodePassword(pwdstr);
pwdstr.JsonEscapeForEncryptPassword();
strcpy(pwd, pwdstr.GetString());
encodestr=pwdstr.EncodeBase64Password();
//strcpy(pwd, pwdstr.GetString());
dirstr.SetAs(directory);
wyIni::IniWriteString(conn.GetString(), "Password", pwdstr.GetString(), dirstr.GetString());
wyIni::IniWriteString(conn.GetString(), "Password", encodestr, dirstr.GetString());
}

/*Gets the 'AutocompleteTagbuilded' info from .ini to decides the statusbar message to be 'Building tags' or 'Rebuilding tags'
Expand All @@ -1759,6 +1765,8 @@ ConnectionBase::GetInitialDetails(HWND hdlg)
SetAutocompleteTagBuildFlag(&conn, &dirstr);

//SetFocus(GetDlgItem(hdlg, IDOK));
if (encodestr)
free(encodestr);

return wyTrue;
}
Expand Down Expand Up @@ -2631,11 +2639,17 @@ ConnectionBase::SaveServerDetails(HWND hwnd, const wyChar *conn, const wyChar *d
{
ret = SendMessage(GetDlgItem(hwnd, IDC_DLGCONNECT_PASSWORD), WM_GETTEXT, sizeof(temp), (LPARAM)temp);
tempstr.SetAs(temp);
tempstr.JsonEscapeForEncryptPassword();
EncodePassword(tempstr);
tempstr.JsonEscapeForEncryptPassword();
ret = wyIni::IniWriteString(conn, "Password", tempstr.GetString(), directory);

//wyChar *encodestr = NULL;
/*encodestr = AllocateBuff(512);
EncodeBase64(tempstr.GetString(), tempstr.GetLength(), &encodestr);*/
wyChar *encodestr = tempstr.EncodeBase64Password();
ret = wyIni::IniWriteString(conn, "Password", encodestr, directory);
wyIni::IniWriteString(conn, "Isencrypted", "1", directory);

if(encodestr)
free(encodestr);
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions src/ConnectionCommunity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,11 @@ ConnectionCommunity::OnConnect(HWND hwnd, ConnectionInfo * dbname)
GetWindowText(GetDlgItem(hwnd, IDC_DLGCONNECT_PASSWORD), pass, MAX_PATH);
temp.SetAs(pass);
EncodePassword(temp);
wyChar *encodestr = temp.EncodeBase64Password();
temp.SetAs(encodestr);
wyIni::IniWriteString(conn.GetString(), "Password", temp.GetString(), dirnamestr.GetString());
if (encodestr)
free(encodestr);
}

/* write the store password value too */
Expand Down
9 changes: 6 additions & 3 deletions src/FrameWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6712,12 +6712,15 @@ FrameWindow::ConvertAndWritePwd(wyString &conncount, wyChar *whichpwd, wyString
wyIni::IniGetString(conncount.GetString(), whichpwd, "", &passwordstr, path.GetString());
if(passwordstr.GetLength())
{
wyString::JsonDeEscapeForEncryptPassword(passwordstr);
wyString::DecodeBase64Password(passwordstr);
DecodePassword(passwordstr);
temppwd.SetAs(passwordstr.GetString(), wyFalse);
EncodePassword(temppwd);
temppwd.JsonEscapeForEncryptPassword();
wyIni::IniWriteString(conncount.GetString(), whichpwd, temppwd.GetString(), path.GetString());
wyChar * encodestr=temppwd.EncodeBase64Password();
wyIni::IniWriteString(conncount.GetString(), whichpwd, encodestr, path.GetString());

if (encodestr)
free(encodestr);
}

}
Expand Down
56 changes: 42 additions & 14 deletions src/GUIHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9166,7 +9166,7 @@ wyBool GetSessionDetails(wyWChar* conn, wyWChar* path, ConnectionInfo *conninfo,
conninfo->m_isstorepwd = inimgr->IniGetInt2(connstr.GetString(), "StorePassword", 1, pathstr.GetString()) ? wyTrue: wyFalse;
inimgr->IniGetString2(connstr.GetString(), "Password", "", &conninfo->m_pwd, pathstr.GetString());

wyString::JsonDeEscapeForEncryptPassword(conninfo->m_pwd);
wyString::DecodeBase64Password(conninfo->m_pwd);
DecodePassword(conninfo->m_pwd);

conninfo->m_port = inimgr->IniGetInt2(connstr.GetString(), "Port", 3306, pathstr.GetString());
Expand Down Expand Up @@ -9210,7 +9210,7 @@ wyBool GetSessionDetails(wyWChar* conn, wyWChar* path, ConnectionInfo *conninfo,

if (proxypwd.GetLength())
{
wyString::JsonDeEscapeForEncryptPassword(proxypwd);
wyString::DecodeBase64Password(proxypwd);
DecodePassword(proxypwd);
}
wcscpy(auth->proxypwd, proxypwd.GetAsWideChar());
Expand All @@ -9223,7 +9223,7 @@ wyBool GetSessionDetails(wyWChar* conn, wyWChar* path, ConnectionInfo *conninfo,

if (chalpwd.GetLength())
{
wyString::JsonDeEscapeForEncryptPassword(chalpwd);
wyString::DecodeBase64Password(chalpwd);
DecodePassword(chalpwd);
}

Expand All @@ -9240,7 +9240,7 @@ wyBool GetSessionDetails(wyWChar* conn, wyWChar* path, ConnectionInfo *conninfo,
conninfo->m_isssh = inimgr->IniGetInt2(connstr.GetString(), "SSH", 0, pathstr.GetString()) ? wyTrue: wyFalse;
inimgr->IniGetString2(connstr.GetString(), "SshUser", "", &conninfo->m_sshuser, pathstr.GetString());
inimgr->IniGetString2(connstr.GetString(), "SshPwd", "", &conninfo->m_sshpwd, pathstr.GetString());
wyString::JsonDeEscapeForEncryptPassword(conninfo->m_sshpwd);
wyString::DecodeBase64Password(conninfo->m_sshpwd);
DecodePassword(conninfo->m_sshpwd);
inimgr->IniGetString2(connstr.GetString(), "SshHost", "", &conninfo->m_sshhost, pathstr.GetString());
conninfo->m_sshport = inimgr->IniGetInt2 (connstr.GetString(), "SshPort", 0, pathstr.GetString());
Expand Down Expand Up @@ -9594,7 +9594,7 @@ wyBool GetSessionDetailsFromTable(wyWChar* path, ConnectionInfo *conninfo, wyInt
conninfo->m_pwd.SetAs(pwdstr);

}
wyString::JsonDeEscapeForEncryptPassword(conninfo->m_pwd);
wyString::DecodeBase64Password(conninfo->m_pwd);
DecodePassword(conninfo->m_pwd);
colval = sqliteobj->GetText(&res , "Port");
if(colval)
Expand Down Expand Up @@ -9703,7 +9703,7 @@ wyBool GetSessionDetailsFromTable(wyWChar* path, ConnectionInfo *conninfo, wyInt

if (proxypwd.GetLength())
{
wyString::JsonDeEscapeForEncryptPassword(proxypwd);
wyString::DecodeBase64Password(proxypwd);
DecodePassword(proxypwd);
}
wcscpy(auth->proxypwd, proxypwd.GetAsWideChar());
Expand All @@ -9724,7 +9724,7 @@ wyBool GetSessionDetailsFromTable(wyWChar* path, ConnectionInfo *conninfo, wyInt
}
if (chalpwd.GetLength())
{
wyString::JsonDeEscapeForEncryptPassword(chalpwd);
wyString::DecodeBase64Password(chalpwd);
DecodePassword(chalpwd);
}

Expand Down Expand Up @@ -9762,8 +9762,7 @@ wyBool GetSessionDetailsFromTable(wyWChar* path, ConnectionInfo *conninfo, wyInt
{
MigratePassword(conninfo->m_sshpwd);
}

wyString::JsonDeEscapeForEncryptPassword(conninfo->m_sshpwd);
wyString::DecodeBase64Password(conninfo->m_sshpwd);
DecodePassword(conninfo->m_sshpwd);

colval = sqliteobj->GetText(&res , "SshHost");
Expand Down Expand Up @@ -9931,10 +9930,14 @@ WriteFullSectionToFile(FILE *out_stream, wyInt32 conno, ConnectionInfo *coninfo,
pass.SetAs(coninfo->m_pwd);
}
EncodePassword(pass);
pass.JsonEscapeForEncryptPassword();
wyChar *encodestr=pass.EncodeBase64Password();
pass.SetAs(encodestr);
temp.Sprintf("Password=%s\r\n", pass.GetString());
fputs(temp.GetString(), out_stream);

if (encodestr)
free(encodestr);

temp.Sprintf("Port=%d\r\n", coninfo->m_port);
fputs(temp.GetString(), out_stream);

Expand Down Expand Up @@ -10001,7 +10004,10 @@ WriteFullSectionToFile(FILE *out_stream, wyInt32 conno, ConnectionInfo *coninfo,
if (tempstr.GetLength() != 0)
{
EncodePassword(tempstr);
tempstr.JsonEscapeForEncryptPassword();
wyChar *encodestr=tempstr.EncodeBase64Password();
tempstr.SetAs(encodestr);
if (encodestr)
free(encodestr);
}

temp.Sprintf("ProxyPwd=%s\r\n", tempstr.GetString());
Expand All @@ -10019,7 +10025,10 @@ WriteFullSectionToFile(FILE *out_stream, wyInt32 conno, ConnectionInfo *coninfo,
if (tempstr.GetLength())
{
EncodePassword(tempstr);
tempstr.JsonEscapeForEncryptPassword();
wyChar *encodestr=tempstr.EncodeBase64Password();
tempstr.SetAs(encodestr);
if (encodestr)
free(encodestr);
}

temp.Sprintf("401Pwd=%s\r\n", tempstr.GetString());
Expand All @@ -10043,7 +10052,10 @@ WriteFullSectionToFile(FILE *out_stream, wyInt32 conno, ConnectionInfo *coninfo,
if(tempstr.GetLength())
{
EncodePassword(tempstr);
tempstr.JsonEscapeForEncryptPassword();
wyChar *encodestr=tempstr.EncodeBase64Password();
tempstr.SetAs(encodestr);
if (encodestr)
free(encodestr);
}

temp.Sprintf("SshPwd=%s\r\n", tempstr.GetString());
Expand Down Expand Up @@ -10199,9 +10211,12 @@ WriteFullSectionToTable(wyString *sqlitequery, wyInt32 id, wyInt32 position, Con
pass.SetAs(coninfo->m_pwd);
}
EncodePassword(pass);
wyChar *encodestr=pass.EncodeBase64Password();
wyString password("");
password.SetAs(encodestr);
//pass.JsonEscapeForEncryptPassword();

sqliteobj->SetText(&stmt, 9, pass.GetLength()?pass.GetString():"");
sqliteobj->SetText(&stmt, 9, password.GetLength()?password.GetString():"");

sqliteobj->SetInt(&stmt, 10, coninfo->m_port);

Expand Down Expand Up @@ -10264,10 +10279,15 @@ WriteFullSectionToTable(wyString *sqlitequery, wyInt32 id, wyInt32 position, Con


tempstr.SetAs(auth->proxypwd);
wyChar* encodestr = NULL;
if (tempstr.GetLength() != 0)
{
EncodePassword(tempstr);
encodestr = tempstr.EncodeBase64Password();
tempstr.SetAs(encodestr);
}
if (encodestr)
free(encodestr);

sqliteobj->SetText(&stmt, 26, tempstr.GetLength() ? tempstr.GetString() : "");

Expand All @@ -10285,6 +10305,10 @@ WriteFullSectionToTable(wyString *sqlitequery, wyInt32 id, wyInt32 position, Con
if (tempstr.GetLength())
{
EncodePassword(tempstr);
wyChar* encodestr=tempstr.EncodeBase64Password();
tempstr.SetAs(encodestr);
if (encodestr)
free(encodestr);
}

sqliteobj->SetText(&stmt, 29, tempstr.GetLength()? tempstr.GetString():"");
Expand All @@ -10306,6 +10330,10 @@ WriteFullSectionToTable(wyString *sqlitequery, wyInt32 id, wyInt32 position, Con
if(tempstr.GetLength())
{
EncodePassword(tempstr);
wyChar* encodestr = tempstr.EncodeBase64Password();
tempstr.SetAs(encodestr);
if (encodestr)
free(encodestr);
}

sqliteobj->SetText(&stmt, 34, tempstr.GetLength()? tempstr.GetString():"");
Expand Down
Loading

0 comments on commit 4204685

Please sign in to comment.