summaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_encryption.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-12-28 18:21:11 +0100
committerJay Berkenbilt <ejb@ql.org>2012-12-31 16:32:31 +0100
commit16a23368e738be88669f4fbf4d3341dd473519c7 (patch)
tree4dbe3f137fe08e03e83d3e477069c6a4255b5dc2 /libqpdf/QPDF_encryption.cc
parent8f5de08c2ae5d2c01488887f3141b6fe3eb67779 (diff)
downloadqpdf-16a23368e738be88669f4fbf4d3341dd473519c7.tar.zst
Fix infinite loop trimming passwords with ( in them
Diffstat (limited to 'libqpdf/QPDF_encryption.cc')
-rw-r--r--libqpdf/QPDF_encryption.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index 43bc62ba..6ab51a03 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -141,14 +141,20 @@ QPDF::trim_user_password(std::string& user_password)
return;
}
- char const* p = 0;
- while ((p = strchr(cstr, '\x28')) != 0)
+ char const* p1 = cstr;
+ char const* p2 = 0;
+ while ((p2 = strchr(p1, '\x28')) != 0)
{
- if (memcmp(p, padding_string, len - (p - cstr)) == 0)
+ if (memcmp(p2, padding_string, len - (p2 - cstr)) == 0)
{
- user_password = user_password.substr(0, p - cstr);
+ user_password = user_password.substr(0, p2 - cstr);
return;
}
+ else
+ {
+ QTC::TC("qpdf", "QPDF_encryption skip 0x28");
+ p1 = p2 + 1;
+ }
}
}