selftests/net: rxtimestamp: Fix an off by one
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 5 Oct 2017 12:53:47 +0000 (15:53 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 6 Oct 2017 04:28:53 +0000 (21:28 -0700)
The > should be >= so that we don't write one element beyond the end of
the array.

Fixes: 16e781224198 ("selftests/net: Add a test to validate behavior of rx timestamps")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/networking/timestamping/rxtimestamp.c

index 00f286661dcd2c0459941e03dcccf0af4d17fd37..dd4162fc0419bca7a7dccd17db8b99b61fb7f4a3 100644 (file)
@@ -341,7 +341,7 @@ int main(int argc, char **argv)
                        return 0;
                case 'n':
                        t = atoi(optarg);
-                       if (t > ARRAY_SIZE(test_cases))
+                       if (t >= ARRAY_SIZE(test_cases))
                                error(1, 0, "Invalid test case: %d", t);
                        all_tests = false;
                        test_cases[t].enabled = true;