diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-01-30 15:04:09 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-01-30 16:45:42 +0000 |
commit | b87df03423b345ad83f1911db476d5ce50b8d0fb (patch) | |
tree | 76b10adb8bc5eb97213be4ee3fd13a954b57c654 /connectivity | |
parent | tdf#105448 add Sibe [nco-PG] to language list (diff) | |
download | core-b87df03423b345ad83f1911db476d5ce50b8d0fb.tar.gz core-b87df03423b345ad83f1911db476d5ce50b8d0fb.zip |
ditch fixed length buffer
Change-Id: I06bbe4ee92ebeb7d1bc305d5a7da9ee9a4fa0cb8
Reviewed-on: https://gerrit.libreoffice.org/33706
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/Connection.cxx | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 7985e6184886..34c808989b2b 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -240,27 +240,22 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV } } - char dpbBuffer[1 + 3 + 257 + 257 + 5 ]; // Expand as needed - int dpbLength = 0; + std::string dpbBuffer; { - char* dpb; char userName[256] = ""; char userPassword[256] = ""; - dpb = dpbBuffer; - *dpb++ = isc_dpb_version1; - - *dpb++ = isc_dpb_sql_dialect; - *dpb++ = 1; // 1 byte long - *dpb++ = FIREBIRD_SQL_DIALECT; + dpbBuffer.push_back(isc_dpb_version1); + dpbBuffer.push_back(isc_dpb_sql_dialect); + dpbBuffer.push_back(1); // 1 byte long + dpbBuffer.push_back(FIREBIRD_SQL_DIALECT); // set UTF8 as default character set const char sCharset[] = "UTF8"; - *dpb++ = isc_dpb_set_db_charset; + dpbBuffer.push_back(isc_dpb_set_db_charset); int nCharsetLength = sizeof(sCharset) - 1; - *dpb++ = (char) nCharsetLength; - strcpy(dpb, sCharset); - dpb+= nCharsetLength; + dpbBuffer.push_back(nCharsetLength); + dpbBuffer.append(sCharset); // Do any more dpbBuffer additions here @@ -277,22 +272,18 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV if (strlen(userName)) { int nUsernameLength = strlen(userName); - *dpb++ = isc_dpb_user_name; - *dpb++ = (char) nUsernameLength; - strcpy(dpb, userName); - dpb+= nUsernameLength; + dpbBuffer.push_back(isc_dpb_user_name); + dpbBuffer.push_back(nUsernameLength); + dpbBuffer.append(userName); } if (strlen(userPassword)) { int nPasswordLength = strlen(userPassword); - *dpb++ = isc_dpb_password; - *dpb++ = (char) nPasswordLength; - strcpy(dpb, userPassword); - dpb+= nPasswordLength; + dpbBuffer.push_back(isc_dpb_password); + dpbBuffer.push_back(nPasswordLength); + dpbBuffer.append(userPassword); } - - dpbLength = dpb - dpbBuffer; } ISC_STATUS_ARRAY status; /* status vector */ @@ -303,8 +294,8 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV m_sFirebirdURL.getLength(), OUStringToOString(m_sFirebirdURL,RTL_TEXTENCODING_UTF8).getStr(), &m_aDBHandle, - dpbLength, - dpbBuffer, + dpbBuffer.size(), + dpbBuffer.c_str(), 0); if (aErr) { @@ -322,8 +313,8 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV m_sFirebirdURL.getLength(), OUStringToOString(m_sFirebirdURL, RTL_TEXTENCODING_UTF8).getStr(), &m_aDBHandle, - dpbLength, - dpbBuffer); + dpbBuffer.size(), + dpbBuffer.c_str()); if (aErr) { evaluateStatusVector(status, "isc_attach_database", *this); |