From a0f797203e35e91275d196b3f2d3679d87ec20b5 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Wed, 16 Dec 2015 09:23:40 +0100 Subject: [PATCH] GH #1087: prevent line breaks in base64-encoded creds --- Net/src/SMTPClientSession.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Net/src/SMTPClientSession.cpp b/Net/src/SMTPClientSession.cpp index 8399ac7de..f72b4b3a5 100644 --- a/Net/src/SMTPClientSession.cpp +++ b/Net/src/SMTPClientSession.cpp @@ -148,6 +148,7 @@ void SMTPClientSession::loginUsingCRAM(const std::string& username, const std::s std::ostringstream challengeResponseBase64; Base64Encoder encoder(challengeResponseBase64); + encoder.rdbuf()->setLineLength(0); encoder << challengeResponse; encoder.close(); @@ -164,11 +165,13 @@ void SMTPClientSession::loginUsingLogin(const std::string& username, const std:: std::ostringstream usernameBase64; Base64Encoder usernameEncoder(usernameBase64); + usernameEncoder.rdbuf()->setLineLength(0); usernameEncoder << username; usernameEncoder.close(); std::ostringstream passwordBase64; Base64Encoder passwordEncoder(passwordBase64); + passwordEncoder.rdbuf()->setLineLength(0); passwordEncoder << password; passwordEncoder.close(); @@ -211,6 +214,7 @@ void SMTPClientSession::loginUsingPlain(const std::string& username, const std:: { std::ostringstream credentialsBase64; Base64Encoder credentialsEncoder(credentialsBase64); + credentialsEncoder.rdbuf()->setLineLength(0); credentialsEncoder << '\0' << username << '\0' << password; credentialsEncoder.close(); @@ -224,6 +228,7 @@ void SMTPClientSession::loginUsingXOAUTH2(const std::string& username, const std { std::ostringstream credentialsBase64; Base64Encoder credentialsEncoder(credentialsBase64); + credentialsEncoder.rdbuf()->setLineLength(0); credentialsEncoder << "user=" << username << "\001auth=Bearer " << password << "\001\001"; credentialsEncoder.close();