summaryrefslogtreecommitdiff
path: root/apt-pkg/tagfile.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-08-12 20:44:40 +0200
committerJulian Andres Klode <jak@debian.org>2015-08-12 20:51:08 +0200
commit809aa216c630f1cc61b0c3b9d992d4a3be14be3c (patch)
tree8e742b619907e2400897e3667fb7b1ae45af6b57 /apt-pkg/tagfile.cc
parentf3f06cae53d8ed5742f47de46d9f9808cfc5ec29 (diff)
policy: Be more strict about parsing pin files, and document prio 0
Treat invalid pin priorities and overflows as an error. Closes: #429912
Diffstat (limited to 'apt-pkg/tagfile.cc')
-rw-r--r--apt-pkg/tagfile.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 253b1b7a3..8acecd735 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -533,9 +533,16 @@ signed int pkgTagSection::FindI(const char *Tag,signed long Default) const
return Default;
strncpy(S,Start,Stop-Start);
S[Stop - Start] = 0;
-
+
+ errno = 0;
char *End;
signed long Result = strtol(S,&End,10);
+ if (errno == ERANGE)
+ _error->Errno("strtol", _("Cannot convert %s to integer"), S);
+ if (Result < std::numeric_limits<int>::min() || Result > std::numeric_limits<int>::max()) {
+ errno = ERANGE;
+ _error->Errno("", _("Cannot convert %s to integer"), S);
+ }
if (S == End)
return Default;
return Result;