From 1868a10f8b06631362618bfc85ca8646da4b4b71 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 29 Aug 2017 12:27:59 -0400 Subject: Replace all atoi calls with QUtil::string_to_int The latter catches underflow/overflow. --- libqpdf/QPDFWriter.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libqpdf/QPDFWriter.cc') diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index ee2ab32e..1ce4bfb6 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -661,8 +661,10 @@ QPDFWriter::disableIncompatibleEncryption(int major, int minor, } else { - int V = atoi(this->m->encryption_dictionary["/V"].c_str()); - int R = atoi(this->m->encryption_dictionary["/R"].c_str()); + int V = QUtil::string_to_int( + this->m->encryption_dictionary["/V"].c_str()); + int R = QUtil::string_to_int( + this->m->encryption_dictionary["/R"].c_str()); if (compareVersions(major, minor, 1, 4) < 0) { if ((V > 1) || (R > 2)) @@ -705,12 +707,12 @@ void QPDFWriter::parseVersion(std::string const& version, int& major, int& minor) const { - major = atoi(version.c_str()); + major = QUtil::string_to_int(version.c_str()); minor = 0; size_t p = version.find('.'); if ((p != std::string::npos) && (version.length() > p)) { - minor = atoi(version.substr(p + 1).c_str()); + minor = QUtil::string_to_int(version.substr(p + 1).c_str()); } std::string tmp = QUtil::int_to_string(major) + "." + QUtil::int_to_string(minor); -- cgit v1.2.3-70-g09d2