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/QPDF.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libqpdf/QPDF.cc') diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 86e798ee..bea83c98 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -440,8 +440,8 @@ QPDF::reconstruct_xref(QPDFExc& e) (t3 == QPDFTokenizer::Token(QPDFTokenizer::tt_word, "obj"))) { in_obj = true; - int obj = atoi(t1.getValue().c_str()); - int gen = atoi(t2.getValue().c_str()); + int obj = QUtil::string_to_int(t1.getValue().c_str()); + int gen = QUtil::string_to_int(t2.getValue().c_str()); insertXrefEntry(obj, 1, token_start, gen, true); } } @@ -610,8 +610,8 @@ QPDF::parse_xrefFirst(std::string const& line, ++p; } bytes = p - start; - obj = atoi(obj_str.c_str()); - num = atoi(num_str.c_str()); + obj = QUtil::string_to_int(obj_str.c_str()); + num = QUtil::string_to_int(num_str.c_str()); return true; } @@ -706,7 +706,7 @@ QPDF::parse_xrefEntry(std::string const& line, } f1 = QUtil::string_to_ll(f1_str.c_str()); - f2 = atoi(f2_str.c_str()); + f2 = QUtil::string_to_int(f2_str.c_str()); return true; } @@ -1570,8 +1570,8 @@ QPDF::readObjectAtOffset(bool try_recovery, this->m->last_object_description, offset, "expected n n obj"); } - objid = atoi(tobjid.getValue().c_str()); - generation = atoi(tgen.getValue().c_str()); + objid = QUtil::string_to_int(tobjid.getValue().c_str()); + generation = QUtil::string_to_int(tgen.getValue().c_str()); if (objid == 0) { @@ -1855,7 +1855,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) "expected integer in object stream header"); } - int num = atoi(tnum.getValue().c_str()); + int num = QUtil::string_to_int(tnum.getValue().c_str()); int offset = QUtil::string_to_ll(toffset.getValue().c_str()); offsets[num] = offset + first; } -- cgit v1.2.3-54-g00ecf