diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-05-01 21:43:43 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2017-08-26 02:14:44 +0100 |
commit | 888d12a24768e4f448fc8a58f25fcdf6dce5095f (patch) | |
tree | 852bd6e0f9851ce7e44c81ccb03ce0449e86c174 | |
parent | ce5dde3961dc7cc78404689609e995a6123d2ba2 (diff) | |
download | linux-stable-888d12a24768e4f448fc8a58f25fcdf6dce5095f.tar.gz linux-stable-888d12a24768e4f448fc8a58f25fcdf6dce5095f.tar.bz2 linux-stable-888d12a24768e4f448fc8a58f25fcdf6dce5095f.zip |
cifs: small underflow in cnvrtDosUnixTm()
commit 564277eceeca01e02b1ef3e141cfb939184601b4 upstream.
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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | fs/cifs/netmisc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index 6834b9c3bec1..f2cb1db1b202 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c @@ -966,10 +966,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]; |