Skip to content

Commit

Permalink
Merge pull request #388 from ksooo/fix-logger-buffer-overflow
Browse files Browse the repository at this point in the history
4.4.5 - Fix buffer overflow in Logger::Log
  • Loading branch information
ksooo authored Dec 17, 2018
2 parents 6a12442 + 5027928 commit 73512af
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pvr.hts/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hts"
version="4.4.4"
version="4.4.5"
name="Tvheadend HTSP Client"
provider-name="Adam Sutton, Sam Stenvall, Lars Op den Kamp, Kai Sommerfeld">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
9 changes: 9 additions & 0 deletions pvr.hts/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
4.4.5
- Fixed buffer overflow in Logger::Log

4.4.4
- updated language files from Transifex

4.4.3
- updated language files from Transifex

4.4.2
- Fix RDS stream support. Only mpeg2 audio streams can contain embedded RDS data and there can be at most one RDS stream at a time.

Expand Down
15 changes: 8 additions & 7 deletions src/tvheadend/utilities/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "Logger.h"

#include <cstdarg>
#include "p8-platform/util/StringUtils.h"

using namespace tvheadend::utilities;

Expand All @@ -44,20 +44,21 @@ void Logger::Log(LogLevel level, const char *message, ...)
{
auto &logger = GetInstance();

char buffer[MESSAGE_BUFFER_SIZE];
std::string logMessage = message;
std::string prefix = logger.m_prefix;
std::string logMessage;

// Prepend the prefix when set
const std::string prefix = logger.m_prefix;
if (!prefix.empty())
logMessage = prefix + " - " + message;
logMessage = prefix + " - ";

logMessage += message;

va_list arguments;
va_start(arguments, message);
vsprintf(buffer, logMessage.c_str(), arguments);
logMessage = StringUtils::FormatV(logMessage.c_str(), arguments);
va_end(arguments);

logger.m_implementation(level, buffer);
logger.m_implementation(level, logMessage.c_str());
}

void Logger::SetImplementation(LoggerImplementation implementation)
Expand Down
2 changes: 0 additions & 2 deletions src/tvheadend/utilities/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ namespace tvheadend
void SetPrefix(const std::string &prefix);

private:
static const unsigned int MESSAGE_BUFFER_SIZE = 16384;

Logger();

/**
Expand Down

0 comments on commit 73512af

Please sign in to comment.