summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-05-09 15:46:20 +0200
committerlouiz’ <louiz@louiz.org>2017-05-09 15:46:20 +0200
commitf7e4adb10bff1c278a8543b230b10881ff3799fa (patch)
tree3b78a631533ad71b2c76f33081bad98fccc79753 /src/xmpp
parentc046d2ea984a3a5e4069604dc4f61c2f9e60ca44 (diff)
downloadbiboumi-f7e4adb10bff1c278a8543b230b10881ff3799fa.tar.gz
biboumi-f7e4adb10bff1c278a8543b230b10881ff3799fa.tar.bz2
biboumi-f7e4adb10bff1c278a8543b230b10881ff3799fa.tar.xz
biboumi-f7e4adb10bff1c278a8543b230b10881ff3799fa.zip
Avoid any potential int overflow
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/xmpp_component.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 35abbee..b138ed9 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -112,17 +112,20 @@ void XmppComponent::on_connection_close(const std::string& error)
void XmppComponent::parse_in_buffer(const size_t size)
{
+ // in_buf.size, or size, cannot be bigger than our read-size (4096) so it’s safe
+ // to cast.
+
if (!this->in_buf.empty())
{ // This may happen if the parser could not allocate enough space for
// us. We try to feed it the data that was read into our in_buf
// instead. If this fails again we are in trouble.
- this->parser.feed(this->in_buf.data(), this->in_buf.size(), false);
+ this->parser.feed(this->in_buf.data(), static_cast<int>(this->in_buf.size()), false);
this->in_buf.clear();
}
else
{ // Just tell the parser to parse the data that was placed into the
// buffer it provided to us with GetBuffer
- this->parser.parse(size, false);
+ this->parser.parse(static_cast<int>(size), false);
}
}