From: Odin Ugedal <odin@ugedal.com>
To: toke@redhat.com, netdev@vger.kernel.org
Cc: Odin Ugedal <odin@ugedal.com>
Subject: [PATCH 3/3] q_cake: detect overflow in get_size
Date: Wed, 15 Apr 2020 16:39:36 +0200 [thread overview]
Message-ID: <20200415143936.18924-4-odin@ugedal.com> (raw)
In-Reply-To: <20200415143936.18924-1-odin@ugedal.com>
This detects overflow during parsing of value:
eg. running:
$ tc qdisc add dev lo root cake memlimit 11gb
currently gives a memlimit of "3072Mb", while with this patch it errors
with 'illegal value for "memlimit": "11gb"', since memlinit is an
unsigned integer.
Signed-off-by: Odin Ugedal <odin@ugedal.com>
---
tc/tc_util.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 5f13d729..68938fb0 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -385,6 +385,11 @@ int get_size(unsigned int *size, const char *str)
}
*size = sz;
+
+ /* detect if an overflow happened */
+ if (*size != floor(sz))
+ return -1;
+
return 0;
}
--
2.26.1
next prev parent reply other threads:[~2020-04-15 14:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 14:39 [PATCH 0/3] q_cake: minor fixes and cleanups Odin Ugedal
2020-04-15 14:39 ` [PATCH 1/3] q_cake: Make fwmark uint instead of int Odin Ugedal
2020-04-16 8:47 ` Toke Høiland-Jørgensen
2020-04-15 14:39 ` [PATCH 2/3] q_cake: properly print memlimit Odin Ugedal
2020-04-16 8:47 ` Toke Høiland-Jørgensen
2020-04-15 14:39 ` Odin Ugedal [this message]
2020-04-16 8:49 ` [PATCH 3/3] q_cake: detect overflow in get_size Toke Høiland-Jørgensen
2020-04-16 14:11 ` Odin Ugedal
2020-04-16 14:08 ` [PATCH v2 3/3] tc_util: " Odin Ugedal
2020-04-16 14:16 ` Toke Høiland-Jørgensen
2020-04-20 16:37 ` [PATCH 0/3] q_cake: minor fixes and cleanups Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200415143936.18924-4-odin@ugedal.com \
--to=odin@ugedal.com \
--cc=netdev@vger.kernel.org \
--cc=toke@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).