Skip to content
Permalink
Browse files

fix potential segfault if login fails

  • Loading branch information
FernetMenta committed Nov 3, 2017
1 parent 92e4c64 commit 69ed6edac6b89ee8200e51907fa857b7a7e08f88
Showing with 13 additions and 21 deletions.
  1. +1 −1 pvr.vdr.vnsi/addon.xml.in
  2. +12 −20 src/VNSISession.cpp
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.vdr.vnsi"
version="3.4.4"
version="3.4.5"
name="VDR VNSI Client"
provider-name="FernetMenta, Team Kodi">
<requires>@ADDON_DEPENDS@</requires>
@@ -121,43 +121,35 @@ bool cVNSISession::Login()
if (!vresp)
throw "failed to read greeting from server";

uint32_t protocol = vresp->extract_U32();
uint32_t vdrTime = vresp->extract_U32();
int32_t vdrTimeOffset = vresp->extract_S32();
const char *ServerName = vresp->extract_String();
uint32_t protocol = vresp->extract_U32();
uint32_t vdrTime = vresp->extract_U32();
int32_t vdrTimeOffset = vresp->extract_S32();
const char *ServerName = vresp->extract_String();
const char *ServerVersion = vresp->extract_String();

m_server = ServerName;
m_version = ServerVersion;
m_protocol = (int)protocol;
m_server = ServerName;
m_version = ServerVersion;
m_protocol = (int)protocol;

if (m_protocol < VNSI_MIN_PROTOCOLVERSION)
throw "Protocol versions do not match";

if (m_name.empty())
{
XBMC->Log(LOG_NOTICE, "Logged in at '%lu+%i' to '%s' Version: '%s' with protocol version '%d'",
vdrTime, vdrTimeOffset, ServerName, ServerVersion, protocol);
vdrTime, vdrTimeOffset, ServerName, ServerVersion, protocol);
}
}
catch (const std::out_of_range& e)
{
XBMC->Log(LOG_ERROR, "%s - %s", __FUNCTION__, e.what());
if (m_socket)
{
m_socket->Close();
delete m_socket;
m_socket = NULL;
}
Close();
return false;
}
catch (const char * str)
{
XBMC->Log(LOG_ERROR, "%s - %s", __FUNCTION__,str);
if (m_socket)
{
m_socket->Close();
delete m_socket;
m_socket = NULL;
}
Close();
return false;
}

0 comments on commit 69ed6ed

Please sign in to comment.
You can’t perform that action at this time.