summaryrefslogtreecommitdiff
path: root/dpkg-deb/main.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2012-04-28 18:33:08 +0200
committerGuillem Jover <guillem@debian.org>2012-05-23 09:09:22 +0200
commit2bf4b48a9a6f7ddf854179b4b74013534e4594b9 (patch)
tree5170fb6602115dae040b44a0a5bada113d1f6645 /dpkg-deb/main.c
parent157d6447eee0da5e2e393e205dcdd0bcab404c30 (diff)
downloaddpkg-2bf4b48a9a6f7ddf854179b4b74013534e4594b9.tar.gz
Check parsed integers for out of range errors
Verify that the numbers are not out of the range; i.e. that no negative values are allowed if not appropriate, and that no overflows occur. Closes: #580038
Diffstat (limited to 'dpkg-deb/main.c')
-rw-r--r--dpkg-deb/main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index 812fcae8a..f56eda279 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -3,6 +3,7 @@
* main.c - main program
*
* Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,6 +31,7 @@
#if HAVE_LOCALE_H
#include <locale.h>
#endif
+#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <dirent.h>
@@ -150,8 +152,9 @@ set_compress_level(const struct cmdinfo *cip, const char *value)
long level;
char *end;
+ errno = 0;
level = strtol(value, &end, 0);
- if (value == end || *end || level > INT_MAX)
+ if (value == end || *end || errno != 0)
badusage(_("invalid integer for -%c: '%.250s'"), cip->oshort, value);
if (level < 0 || level > 9)