snic: correctly check for array overrun on overly long version number
authorColin Ian King <colin.king@canonical.com>
Thu, 25 Feb 2016 22:58:25 +0000 (22:58 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 2 Mar 2016 01:08:49 +0000 (20:08 -0500)
The snic version number is expected to be 4 decimals in the form like a
netmask string with each number stored in an element in array v.
However, there is an off-by-one check on the number of elements in v
allowing one to pass a 5 decimal version number causing v[4] to be
referenced, causing a buffer overrun.  Fix the off-by-one error by
comparing to i > 3 rather than 4.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/snic/snic_ctl.c

index aebe75320ed3f22a6147c6aaa0ff7d809709016b..ab0e06b0b4ffa16d3b49d9431978c51b78e9a34d 100644 (file)
@@ -75,7 +75,7 @@ snic_ver_enc(const char *s)
                        continue;
                }
 
-               if (i > 4 || !isdigit(c))
+               if (i > 3 || !isdigit(c))
                        goto end;
 
                v[i] = v[i] * 10 + (c - '0');