Hi,
I'm seeing issues parsing a PDF returning a string with length = -2
(returned by PdfString::GetLength() ) .
The attached patch fixes the invalid length return value, but I'm not sure
if it just masquerades a different problem. Given that I'm not yet familiar
with this part of the code, it would be great if someone could check what's
going on under the hood.
Unfortunately the document triggering the bug is confidential, so I cannot
share it for testing, but I have checked that the attached patch allows me
to correctly parse this PDF.
As always, any feedback greatly appreciated :)
Thanks,
Clemens
--
Clemens Kolbitsch
Security Researcher
kolbit...@lastline.com
805-456-7075
Lastline, Inc.
6950 Hollister Avenue, Suite 101
Goleta, CA 93117
www.lastline.com
diff --git a/podofo-0.9.3/src/base/PdfString.h b/podofo-0.9.3/src/base/PdfString.h
index aac28c5..8cac464 100644
--- a/podofo-0.9.3/src/base/PdfString.h
+++ b/podofo-0.9.3/src/base/PdfString.h
@@ -501,7 +501,8 @@ const std::string & PdfString::GetStringUtf8() const
// -----------------------------------------------------
pdf_long PdfString::GetLength() const
{
- return m_buffer.GetSize() - 2;
+ pdf_long m_buffer_size = m_buffer.GetSize();
+ return (m_buffer_size > 1) ? m_buffer_size - 2 : 0;
}
// -----------------------------------------------------
@@ -517,7 +518,8 @@ pdf_long PdfString::GetCharacterLength() const
// -----------------------------------------------------
pdf_long PdfString::GetUnicodeLength() const
{
- return (m_buffer.GetSize() / sizeof(pdf_utf16be)) - 1;
+ pdf_long m_buffer_size = m_buffer.GetSize() / sizeof(pdf_utf16be);
+ return (m_buffer_size > 0) ? m_buffer_size - 1 : 0;
}
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users