Improve check for invalid offset and size values. (thx to okozina)

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@588 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
Milan Broz
2011-08-01 12:27:34 +00:00
parent 6361e86daf
commit 7665f8e805
3 changed files with 21 additions and 5 deletions

View File

@@ -29,6 +29,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <limits.h>
#include <libcryptsetup.h>
#include <popt.h>
@@ -1204,8 +1205,11 @@ int main(int argc, const char **argv)
unsigned long long ull_value;
char *endp;
errno = 0;
ull_value = strtoull(popt_tmp, &endp, 0);
if (*endp || !*popt_tmp)
if (*endp || !*popt_tmp ||
(errno == ERANGE && ull_value == ULLONG_MAX) ||
(errno != 0 && ull_value == 0))
r = POPT_ERROR_BADNUMBER;
switch(r) {