Skip to content

Commit

Permalink
webserver: fix crash on HTTP GET arguments without a "=" (fixes #14650)
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese authored and davilla committed Oct 26, 2013
1 parent 102219e commit dfbbc5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions xbmc/network/WebServer.cpp
Expand Up @@ -22,6 +22,7 @@
#ifdef HAS_WEB_SERVER
#include "filesystem/File.h"
#include "utils/log.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/Variant.h"
#include "utils/Base64.h"
Expand Down Expand Up @@ -54,15 +55,21 @@ CWebServer::CWebServer()

int CWebServer::FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
{
if (cls == NULL || key == NULL)
return MHD_NO;

map<string, string> *arguments = (map<string, string> *)cls;
arguments->insert(pair<string,string>(key,value));
arguments->insert(pair<string, string>(key, value != NULL ? value : StringUtils::Empty));
return MHD_YES;
}

int CWebServer::FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
{
if (cls == NULL || key == NULL)
return MHD_NO;

multimap<string, string> *arguments = (multimap<string, string> *)cls;
arguments->insert(pair<string,string>(key,value));
arguments->insert(pair<string, string>(key, value != NULL ? value : StringUtils::Empty));
return MHD_YES;
}

Expand Down
1 change: 1 addition & 0 deletions xbmc/utils/StringUtils.cpp
Expand Up @@ -46,6 +46,7 @@ const char* ADDON_GUID_RE = "^(\\{){0,1}[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-

/* empty string for use in returns by ref */
const CStdString StringUtils::EmptyString = "";
const std::string StringUtils::Empty = "";
CStdString StringUtils::m_lastUUID = "";

string StringUtils::Format(const char *fmt, ...)
Expand Down
1 change: 1 addition & 0 deletions xbmc/utils/StringUtils.h
Expand Up @@ -106,6 +106,7 @@ class StringUtils
static bool IsInteger(const CStdString& str);
static CStdString SizeToString(int64_t size);
static const CStdString EmptyString;
static const std::string Empty;
static size_t FindWords(const char *str, const char *wordLowerCase);
static int FindEndBracket(const CStdString &str, char opener, char closer, int startPos = 0);
static int DateStringToYYYYMMDD(const CStdString &dateString);
Expand Down

0 comments on commit dfbbc5e

Please sign in to comment.