lkml.org 
[lkml]   [2018]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 125/177] cifs: small underflow in cnvrtDosUnixTm()
    Date
    4.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Dan Carpenter <dan.carpenter@oracle.com>


    [ Upstream commit 564277eceeca01e02b1ef3e141cfb939184601b4 ]

    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: Sasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    fs/cifs/netmisc.c | 6 +++---
    1 file changed, 3 insertions(+), 3 deletions(-)

    --- a/fs/cifs/netmisc.c
    +++ b/fs/cifs/netmisc.c
    @@ -980,10 +980,10 @@ struct timespec cnvrtDosUnixTm(__le16 le
    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];

    \
     
     \ /
      Last update: 2018-03-23 11:11    [W:4.686 / U:0.048 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site