summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StreamStack/XMPPLayer.cpp')
-rw-r--r--Swiften/StreamStack/XMPPLayer.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp
index 684dfe6..1dcd84f 100644
--- a/Swiften/StreamStack/XMPPLayer.cpp
+++ b/Swiften/StreamStack/XMPPLayer.cpp
@@ -4,10 +4,10 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/StreamStack/XMPPLayer.h"
-#include "Swiften/Parser/XMPPParser.h"
-#include "Swiften/Serializer/XMPPSerializer.h"
-#include "Swiften/Elements/ProtocolHeader.h"
+#include <Swiften/StreamStack/XMPPLayer.h>
+#include <Swiften/Parser/XMPPParser.h>
+#include <Swiften/Serializer/XMPPSerializer.h>
+#include <Swiften/Elements/ProtocolHeader.h>
namespace Swift {
@@ -29,30 +29,33 @@ XMPPLayer::~XMPPLayer() {
}
void XMPPLayer::writeHeader(const ProtocolHeader& header) {
- writeDataInternal(ByteArray(xmppSerializer_->serializeHeader(header)));
+ writeDataInternal(createSafeByteArray(xmppSerializer_->serializeHeader(header)));
}
void XMPPLayer::writeFooter() {
- writeDataInternal(ByteArray(xmppSerializer_->serializeFooter()));
+ writeDataInternal(createSafeByteArray(xmppSerializer_->serializeFooter()));
}
void XMPPLayer::writeElement(boost::shared_ptr<Element> element) {
- writeDataInternal(ByteArray(xmppSerializer_->serializeElement(element)));
+ writeDataInternal(xmppSerializer_->serializeElement(element));
}
void XMPPLayer::writeData(const std::string& data) {
- writeDataInternal(ByteArray(data));
+ writeDataInternal(createSafeByteArray(data));
}
-void XMPPLayer::writeDataInternal(const ByteArray& data) {
+void XMPPLayer::writeDataInternal(const SafeByteArray& data) {
onWriteData(data);
writeDataToChildLayer(data);
}
-void XMPPLayer::handleDataRead(const ByteArray& data) {
+void XMPPLayer::handleDataRead(const SafeByteArray& data) {
onDataRead(data);
inParser_ = true;
- if (!xmppParser_->parse(data.toString())) {
+ // FIXME: Converting to unsafe string. Should be ok, since we don't take passwords
+ // from the stream in clients. If servers start using this, and require safe storage,
+ // we need to fix this.
+ if (!xmppParser_->parse(byteArrayToString(ByteArray(data.begin(), data.end())))) {
inParser_ = false;
onError();
return;