[PATCH net-next v4 15/17] net: pktgen: num_arg error out in case no valid character is parsed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In num_arg() error out in case no valid character is parsed.

Signed-off-by: Peter Seiderer <ps.report@xxxxxxx>
---
Changes v3 -> v4
  - new patch (factored out of patch 'net: pktgen: fix access outside of user
    given buffer in pktgen_if_write()')
---
 net/core/pktgen.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index cb3b732fd0a3..a46eb20edf6c 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -821,6 +821,9 @@ static long num_arg(const char __user *user_buffer, unsigned long maxlen,
 		if ((c >= '0') && (c <= '9')) {
 			*num *= 10;
 			*num += c - '0';
+		} else if (i == 0) {
+			/* no valid character parsed, error out */
+			return -EINVAL;
 		} else
 			break;
 	}
-- 
2.48.1


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux