summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-05-28 12:58:39 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-05-28 14:30:45 +0200
commit788a38fd32389ba73d5db2b38920768f4af24fb5 (patch)
treea8a57879832ee03943c614979861a0fb358e758b /l10ntools
parentb263b27c014fc1152bedba9f4d999d3f7db1f038 (diff)
Better verification of bad idxdict input
...see dictionaries comits df423c53829faa96f46acd71887fd0f8697c49e9 "fix Lithuanian thesaurus" and 9b6407dadc64e10e7117d8551917b46105ecc6c8 "Fix more thesauri." Change-Id: I6ddc41fce4e3f68d80d05af3320c835b98908fcb
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/source/idxdict/idxdict.cxx12
1 files changed, 11 insertions, 1 deletions
diff --git a/l10ntools/source/idxdict/idxdict.cxx b/l10ntools/source/idxdict/idxdict.cxx
index 67811c08ff5a..035296a233d7 100644
--- a/l10ntools/source/idxdict/idxdict.cxx
+++ b/l10ntools/source/idxdict/idxdict.cxx
@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <cerrno>
#include <iostream>
#include <fstream>
#include <string>
@@ -55,7 +56,16 @@ int main(int argc, char *argv[])
exit(99);
}
currentOffset += strlen(inputBuffer)+1;
- int entryCount(strtol(inputBuffer, NULL, 10));
+ char * endptr;
+ errno = 0;
+ int entryCount(strtol(inputBuffer, &endptr, 10));
+ if (errno != 0 || endptr == inputBuffer || *endptr != '\0')
+ {
+ cerr
+ << "Unable to read count from \"" << inputBuffer
+ << "\" input.\n";
+ exit(99);
+ }
for (int i(0); i < entryCount; ++i)
{
cin.getline(inputBuffer, MAXLINE);