summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2022-04-19 18:54:00 +0200
committerSlávek Banko <slavek.banko@axis.cz>2022-04-20 12:40:48 +0200
commitda925574666b1d0f2d244f110e1833d23442a1de (patch)
tree06293c2ea1923fa0c0e35541031ca993637587fc
parent715ad91506abe0686f394073ac399033d0a2f707 (diff)
downloadtdelibs-da925574666b1d0f2d244f110e1833d23442a1de.tar.gz
tdelibs-da925574666b1d0f2d244f110e1833d23442a1de.zip
TDEMarkdown: Ensure that the loaded file content and generated HTML
are terminated by zero terminator to avoid reading overflow. Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit 0b365bf245fd3b17dfd16d1828fcdbaf0820d947)
-rw-r--r--tdemarkdown/markdown_part.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tdemarkdown/markdown_part.cpp b/tdemarkdown/markdown_part.cpp
index 604873fc3..7ea3d99b1 100644
--- a/tdemarkdown/markdown_part.cpp
+++ b/tdemarkdown/markdown_part.cpp
@@ -73,6 +73,11 @@ bool MarkdownPart::openURL(const KURL& u)
if(!data.isNull())
{
+ if (data[data.size()-1] != '\0')
+ {
+ data.resize(data.size()+1);
+ data[data.size()-1] = '\0';
+ }
begin(u);
TQString parsed(parse((MD_CHAR*) data.data()));
write(parsed);
@@ -109,6 +114,11 @@ TQString& MarkdownPart::parse(MD_CHAR* document)
}
else
{
+ if (data[data.size()-1] != '\0')
+ {
+ data.resize(data.size()+1);
+ data[data.size()-1] = '\0';
+ }
m_buffer += TQString::fromLocal8Bit(data);
}