.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * fs/cifs/netmisc.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * |
---|
7 | 8 | * Error mapping routines from Samba libsmb/errormap.c |
---|
8 | 9 | * Copyright (C) Andrew Tridgell 2001 |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or modify |
---|
11 | | - * it under the terms of the GNU General Public License as published by |
---|
12 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
13 | | - * (at your option) any later version. |
---|
14 | | - * |
---|
15 | | - * This program is distributed in the hope that it will be useful, |
---|
16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
---|
18 | | - * the GNU General Public License for more details. |
---|
19 | | - * |
---|
20 | | - * You should have received a copy of the GNU General Public License |
---|
21 | | - * along with this program; if not, write to the Free Software |
---|
22 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
23 | 10 | */ |
---|
24 | 11 | |
---|
25 | 12 | #include <linux/net.h> |
---|
.. | .. |
---|
894 | 881 | return rc; |
---|
895 | 882 | } |
---|
896 | 883 | |
---|
| 884 | +int |
---|
| 885 | +map_and_check_smb_error(struct mid_q_entry *mid, bool logErr) |
---|
| 886 | +{ |
---|
| 887 | + int rc; |
---|
| 888 | + struct smb_hdr *smb = (struct smb_hdr *)mid->resp_buf; |
---|
| 889 | + |
---|
| 890 | + rc = map_smb_to_linux_error((char *)smb, logErr); |
---|
| 891 | + if (rc == -EACCES && !(smb->Flags2 & SMBFLG2_ERR_STATUS)) { |
---|
| 892 | + /* possible ERRBaduid */ |
---|
| 893 | + __u8 class = smb->Status.DosError.ErrorClass; |
---|
| 894 | + __u16 code = le16_to_cpu(smb->Status.DosError.Error); |
---|
| 895 | + |
---|
| 896 | + /* switch can be used to handle different errors */ |
---|
| 897 | + if (class == ERRSRV && code == ERRbaduid) { |
---|
| 898 | + cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n", |
---|
| 899 | + code); |
---|
| 900 | + spin_lock(&GlobalMid_Lock); |
---|
| 901 | + if (mid->server->tcpStatus != CifsExiting) |
---|
| 902 | + mid->server->tcpStatus = CifsNeedReconnect; |
---|
| 903 | + spin_unlock(&GlobalMid_Lock); |
---|
| 904 | + } |
---|
| 905 | + } |
---|
| 906 | + |
---|
| 907 | + return rc; |
---|
| 908 | +} |
---|
| 909 | + |
---|
| 910 | + |
---|
897 | 911 | /* |
---|
898 | 912 | * calculate the size of the SMB message based on the fixed header |
---|
899 | 913 | * portion, the number of word parameters and the data portion of the message |
---|
.. | .. |
---|
958 | 972 | struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) |
---|
959 | 973 | { |
---|
960 | 974 | struct timespec64 ts; |
---|
961 | | - time64_t sec; |
---|
962 | | - int min, days, month, year; |
---|
| 975 | + time64_t sec, days; |
---|
| 976 | + int min, day, month, year; |
---|
963 | 977 | u16 date = le16_to_cpu(le_date); |
---|
964 | 978 | u16 time = le16_to_cpu(le_time); |
---|
965 | 979 | SMB_TIME *st = (SMB_TIME *)&time; |
---|
.. | .. |
---|
970 | 984 | sec = 2 * st->TwoSeconds; |
---|
971 | 985 | min = st->Minutes; |
---|
972 | 986 | if ((sec > 59) || (min > 59)) |
---|
973 | | - cifs_dbg(VFS, "illegal time min %d sec %lld\n", min, sec); |
---|
| 987 | + cifs_dbg(VFS, "Invalid time min %d sec %lld\n", min, sec); |
---|
974 | 988 | sec += (min * 60); |
---|
975 | 989 | sec += 60 * 60 * st->Hours; |
---|
976 | 990 | if (st->Hours > 24) |
---|
977 | | - cifs_dbg(VFS, "illegal hours %d\n", st->Hours); |
---|
978 | | - days = sd->Day; |
---|
| 991 | + cifs_dbg(VFS, "Invalid hours %d\n", st->Hours); |
---|
| 992 | + day = sd->Day; |
---|
979 | 993 | month = sd->Month; |
---|
980 | | - if (days < 1 || days > 31 || month < 1 || month > 12) { |
---|
981 | | - cifs_dbg(VFS, "illegal date, month %d day: %d\n", month, days); |
---|
982 | | - days = clamp(days, 1, 31); |
---|
| 994 | + if (day < 1 || day > 31 || month < 1 || month > 12) { |
---|
| 995 | + cifs_dbg(VFS, "Invalid date, month %d day: %d\n", month, day); |
---|
| 996 | + day = clamp(day, 1, 31); |
---|
983 | 997 | month = clamp(month, 1, 12); |
---|
984 | 998 | } |
---|
985 | 999 | month -= 1; |
---|
986 | | - days += total_days_of_prev_months[month]; |
---|
| 1000 | + days = day + total_days_of_prev_months[month]; |
---|
987 | 1001 | days += 3652; /* account for difference in days between 1980 and 1970 */ |
---|
988 | 1002 | year = sd->Year; |
---|
989 | 1003 | days += year * 365; |
---|