summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2018-11-09 10:04:04 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2018-11-14 14:18:08 (GMT)
commitccad2debbf8d7322c9d2b517763d7b8e3902a828 (patch)
tree50054ea69dcf21179920ffdde5790908e48848d8 /Swiften/Elements/IBB.h
parentc7ad127218e3901e0006e75aa7e1399b449a845e (diff)
downloadswift-ccad2debbf8d7322c9d2b517763d7b8e3902a828.zip
swift-ccad2debbf8d7322c9d2b517763d7b8e3902a828.tar.bz2
Address bad_numeric_casts for filetransfers
The filetransfer blockSize is now an unsigned integer, as 0 could be used to denote an invalid block size as well (and indeed, already indicated that better than -1 did). All use of numeric_cast in filetransfer code has been fixed to deal with the possibility of thrown exceptions. Test-Information: Unit tests pass on macOS and Debian Change-Id: I1833d553bae071238be20ebc386ef602effb78b0
Diffstat (limited to 'Swiften/Elements/IBB.h')
-rw-r--r--Swiften/Elements/IBB.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/Swiften/Elements/IBB.h b/Swiften/Elements/IBB.h
index bd0b661..6ebe66e 100644
--- a/Swiften/Elements/IBB.h
+++ b/Swiften/Elements/IBB.h
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
@@ -22,22 +22,22 @@ namespace Swift {
Open,
Close,
Data
};
enum StanzaType {
IQStanza,
MessageStanza
};
- IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) {
+ IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(0), sequenceNumber(-1) {
}
- static IBB::ref createIBBOpen(const std::string& streamID, int blockSize) {
+ static IBB::ref createIBBOpen(const std::string& streamID, unsigned int blockSize) {
IBB::ref result = std::make_shared<IBB>(Open, streamID);
result->setBlockSize(blockSize);
return result;
}
static IBB::ref createIBBData(const std::string& streamID, int sequenceNumber, const std::vector<unsigned char>& data) {
IBB::ref result = std::make_shared<IBB>(Data, streamID);
result->setSequenceNumber(sequenceNumber);
result->setData(data);
@@ -74,34 +74,34 @@ namespace Swift {
const std::vector<unsigned char>& getData() const {
return data;
}
void setData(const std::vector<unsigned char>& data) {
this->data = data;
}
- int getBlockSize() const {
+ unsigned int getBlockSize() const {
return blockSize;
}
- void setBlockSize(int blockSize) {
+ void setBlockSize(unsigned int blockSize) {
this->blockSize = blockSize;
}
int getSequenceNumber() const {
return sequenceNumber;
}
void setSequenceNumber(int i) {
sequenceNumber = i;
}
private:
Action action;
std::string streamID;
std::vector<unsigned char> data;
StanzaType stanzaType;
- int blockSize;
+ unsigned int blockSize;
int sequenceNumber;
};
}