]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
cifs: small underflow in cnvrtDosUnixTm()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 1 May 2017 18:43:43 +0000 (21:43 +0300)
committerSteve French <smfrench@gmail.com>
Tue, 2 May 2017 19:57:34 +0000 (14:57 -0500)
January is month 1.  There is no zero-th month.  If someone passes a
zero month then it means we read from one space before the start of the
total_days_of_prev_months[] array.

We may as well also be strict about days as well.

Fixes: 1bd5bbcb6531 ("[CIFS] Legacy time handling for Win9x and OS/2 part 1")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/netmisc.c

index abae6dd2c6b998816db830f40934c86ea8c33fff..cc88f4f0325ef4003bd248c36ca96865ff1b4ddd 100644 (file)
@@ -980,10 +980,10 @@ struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
                cifs_dbg(VFS, "illegal hours %d\n", st->Hours);
        days = sd->Day;
        month = sd->Month;
-       if ((days > 31) || (month > 12)) {
+       if (days < 1 || days > 31 || month < 1 || month > 12) {
                cifs_dbg(VFS, "illegal date, month %d day: %d\n", month, days);
-               if (month > 12)
-                       month = 12;
+               days = clamp(days, 1, 31);
+               month = clamp(month, 1, 12);
        }
        month -= 1;
        days += total_days_of_prev_months[month];