- initialise endptr to NULL before each call to strtoll() - catch empty string - check against LLONG_MAX and LLONG_MIN instead of ULLONG_MAX and 0. Signed-off-by: Yann Droneaud <yann@xxxxxxxxxxx> --- mount/mount.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mount/mount.c b/mount/mount.c index f75a1fb..6df3d61 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1127,29 +1127,33 @@ loop_check(const char **spec, const char **type, int *flags, } else { int loop_opts = SETLOOP_AUTOCLEAR; /* always attempt autoclear */ int res; - char *endptr = NULL; + char *endptr; long long xnum; if (*flags & MS_RDONLY) loop_opts |= SETLOOP_RDONLY; if (opt_offset) { + endptr = NULL; errno = 0; xnum = strtoll(opt_offset, &endptr, 0); - if ((endptr && *endptr) || - (errno != 0 && (xnum == LLONG_MAX || xnum == 0)) || - xnum < 0) { + if ((endptr == opt_offset) || + (endptr && *endptr) || + (errno != 0 && (xnum == LLONG_MAX || xnum == LLONG_MIN)) || + xnum < 0) { error(_("mount: invalid offset '%s' specified"), opt_offset); return EX_FAIL; } offset = xnum; } if (opt_sizelimit) { + endptr = NULL; errno = 0; xnum = strtoll(opt_sizelimit, &endptr, 0); - if ((endptr && *endptr) || - (errno != 0 && (xnum == LLONG_MAX || xnum == 0)) || - xnum < 0) { + if ((endptr == opt_sizelimit) || + (endptr && *endptr) || + (errno != 0 && (xnum == LLONG_MAX || xnum == LLONG_MIN)) || + xnum < 0) { error(_("mount: invalid sizelimit '%s' specified"), opt_sizelimit); return EX_FAIL; } -- 1.6.2.5 -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html