]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
sxgbe: Fix off by one in samsung driver strncpy size arg
authorDominik Czarnota <dominik.b.czarnota@gmail.com>
Mon, 9 Mar 2020 15:22:50 +0000 (16:22 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 12 Mar 2020 06:07:34 +0000 (23:07 -0700)
This patch fixes an off-by-one error in strncpy size argument in
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c. The issue is that in:

        strncmp(opt, "eee_timer:", 6)

the passed string literal: "eee_timer:" has 10 bytes (without the NULL
byte) and the passed size argument is 6. As a result, the logic will
also accept other, malformed strings, e.g. "eee_tiXXX:".

This bug doesn't seem to have any security impact since its present in
module's cmdline parsing code.

Signed-off-by: Dominik Czarnota <dominik.b.czarnota@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c

index c705743d69f7ab5c806c2a8c9ccfbc4b8c0dbf92..2cc8184b7e6b5338864b4f5bf5db57b2d6b2c73f 100644 (file)
@@ -2277,7 +2277,7 @@ static int __init sxgbe_cmdline_opt(char *str)
        if (!str || !*str)
                return -EINVAL;
        while ((opt = strsep(&str, ",")) != NULL) {
-               if (!strncmp(opt, "eee_timer:", 6)) {
+               if (!strncmp(opt, "eee_timer:", 10)) {
                        if (kstrtoint(opt + 10, 0, &eee_timer))
                                goto err;
                }