diff options
author | Jay Berkenbilt <ejb@ql.org> | 2017-08-29 18:27:59 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2017-08-29 18:28:32 +0200 |
commit | 1868a10f8b06631362618bfc85ca8646da4b4b71 (patch) | |
tree | c3029002f777a9904bfa3dff559daea989c79025 /libqpdf/QPDFWriter.cc | |
parent | 742190bd98c0981a07cb39a8eae1e99d909ad5ae (diff) | |
download | qpdf-1868a10f8b06631362618bfc85ca8646da4b4b71.tar.zst |
Replace all atoi calls with QUtil::string_to_int
The latter catches underflow/overflow.
Diffstat (limited to 'libqpdf/QPDFWriter.cc')
-rw-r--r-- | libqpdf/QPDFWriter.cc | 10 |
1 files changed, 6 insertions, 4 deletions
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); |