public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Catch under/overflow cases in cvtnum() and cvttime().
@ 2014-07-11 19:34 Arkadiusz Miśkiewicz
  2014-07-11 23:14 ` Eric Sandeen
  2014-07-13 17:38 ` [PATCH] Init errno before strto* calls Arkadiusz Miśkiewicz
  0 siblings, 2 replies; 12+ messages in thread
From: Arkadiusz Miśkiewicz @ 2014-07-11 19:34 UTC (permalink / raw)
  To: xfs

cvtnum() and cvttime() silently ignore overflows. This leads to error
conditions not being catched. Example:

$ xfs_quota -x -c 'limit -u bsoft=987654321098765432199 \
        bhard=987654321098765432199 999' /
$

Fixed version:
$ xfs_quota -x -c 'limit -u bsoft=987654321098765432199 \
        bhard=987654321098765432199 999' /
xfs_quota: Error: could not parse size 987654321098765432199.
xfs_quota: unrecognised argument bsoft=987654321098765432199

Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
---
 libxcmd/input.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libxcmd/input.c b/libxcmd/input.c
index c06b5b8..397a124 100644
--- a/libxcmd/input.c
+++ b/libxcmd/input.c
@@ -154,6 +154,8 @@ cvtnum(
 	int		c;
 
 	i = strtoll(s, &sp, 0);
+	if ((i == LLONG_MIN || i == LLONG_MAX) && errno == ERANGE)
+		return -1LL;
 	if (i == 0 && sp == s)
 		return -1LL;
 	if (*sp == '\0')
@@ -238,6 +240,8 @@ cvttime(
 	char		*sp;
 
 	i = strtoul(s, &sp, 0);
+	if (i == ULONG_MAX && errno == ERANGE)
+		return 0;
 	if (i == 0 && sp == s)
 		return 0;
 	if (*sp == '\0')
-- 
2.0.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-07-16 23:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11 19:34 [PATCH] Catch under/overflow cases in cvtnum() and cvttime() Arkadiusz Miśkiewicz
2014-07-11 23:14 ` Eric Sandeen
2014-07-12  6:13   ` Arkadiusz Miśkiewicz
2014-07-12 13:37     ` Eric Sandeen
2014-07-12 13:43       ` Eric Sandeen
2014-07-13 17:38 ` [PATCH] Init errno before strto* calls Arkadiusz Miśkiewicz
2014-07-13 23:04   ` Dave Chinner
2014-07-14  7:56     ` [PATCH] Detect strto* failures based on errno Arkadiusz Miśkiewicz
2014-07-16  0:00       ` Dave Chinner
2014-07-16  3:01       ` Dave Chinner
2014-07-16  7:44         ` Arkadiusz Miśkiewicz
2014-07-16 23:32           ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox