Commit f465882d authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] cifs: IPv4-related endianness annotations and bugfixes

missing htons() in assigning .sin_port for reconnect
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 77615fa9
...@@ -313,7 +313,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -313,7 +313,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
connected to port 139 (the NACK is connected to port 139 (the NACK is
since we do not begin with RFC1001 since we do not begin with RFC1001
session initialize frame) */ session initialize frame) */
server->addr.sockAddr.sin_port = CIFS_PORT; server->addr.sockAddr.sin_port = htons(CIFS_PORT);
cifs_reconnect(server); cifs_reconnect(server);
csocket = server->ssocket; csocket = server->ssocket;
wake_up(&server->response_q); wake_up(&server->response_q);
...@@ -849,7 +849,7 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr, ...@@ -849,7 +849,7 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr,
} }
static struct cifsTconInfo * static struct cifsTconInfo *
find_unc(__u32 new_target_ip_addr, char *uncName, char *userName) find_unc(__be32 new_target_ip_addr, char *uncName, char *userName)
{ {
struct list_head *tmp; struct list_head *tmp;
struct cifsTconInfo *tcon; struct cifsTconInfo *tcon;
...@@ -968,7 +968,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket, ...@@ -968,7 +968,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
{ {
int rc = 0; int rc = 0;
int connected = 0; int connected = 0;
unsigned short int orig_port = 0; __be16 orig_port = 0;
if(*csocket == NULL) { if(*csocket == NULL) {
rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket); rc = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, csocket);
...@@ -1076,7 +1076,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket) ...@@ -1076,7 +1076,7 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
{ {
int rc = 0; int rc = 0;
int connected = 0; int connected = 0;
unsigned short int orig_port = 0; __be16 orig_port = 0;
if(*csocket == NULL) { if(*csocket == NULL) {
rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket); rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket);
......
...@@ -315,12 +315,12 @@ checkSMBhdr(struct smb_hdr *smb, __u16 mid) ...@@ -315,12 +315,12 @@ checkSMBhdr(struct smb_hdr *smb, __u16 mid)
int int
checkSMB(struct smb_hdr *smb, __u16 mid, int length) checkSMB(struct smb_hdr *smb, __u16 mid, int length)
{ {
__u32 len = be32_to_cpu(smb->smb_buf_length);
cFYI(0, cFYI(0,
("Entering checkSMB with Length: %x, smb_buf_length: %x ", ("Entering checkSMB with Length: %x, smb_buf_length: %x ",
length, ntohl(smb->smb_buf_length))); length, len));
if (((unsigned int)length < 2 + sizeof (struct smb_hdr)) if (((unsigned int)length < 2 + sizeof (struct smb_hdr)) ||
|| (ntohl(smb->smb_buf_length) > (len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)) {
CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)) {
if ((unsigned int)length < 2 + sizeof (struct smb_hdr)) { if ((unsigned int)length < 2 + sizeof (struct smb_hdr)) {
cERROR(1, ("Length less than 2 + sizeof smb_hdr ")); cERROR(1, ("Length less than 2 + sizeof smb_hdr "));
if (((unsigned int)length >= sizeof (struct smb_hdr) - 1) if (((unsigned int)length >= sizeof (struct smb_hdr) - 1)
...@@ -328,8 +328,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length) ...@@ -328,8 +328,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length)
return 0; /* some error cases do not return wct and bcc */ return 0; /* some error cases do not return wct and bcc */
} }
if (ntohl(smb->smb_buf_length) > if (len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)
CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)
cERROR(1, cERROR(1,
("smb_buf_length greater than CIFS_MAX_MSGSIZE ... ")); ("smb_buf_length greater than CIFS_MAX_MSGSIZE ... "));
cERROR(1, cERROR(1,
...@@ -341,8 +340,8 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length) ...@@ -341,8 +340,8 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length)
if (checkSMBhdr(smb, mid)) if (checkSMBhdr(smb, mid))
return 1; return 1;
if ((4 + ntohl(smb->smb_buf_length) != smbCalcSize(smb)) if ((4 + len != smbCalcSize(smb))
|| (4 + ntohl(smb->smb_buf_length) != (unsigned int)length)) { || (4 + len != (unsigned int)length)) {
return 0; return 0;
} else { } else {
cERROR(1, ("smbCalcSize %x ", smbCalcSize(smb))); cERROR(1, ("smbCalcSize %x ", smbCalcSize(smb)));
......
...@@ -187,8 +187,8 @@ cifs_inet_pton(int address_family, char *cp,void *dst) ...@@ -187,8 +187,8 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
if (value > addr_class_max[end - bytes]) if (value > addr_class_max[end - bytes])
return 0; return 0;
address.s_addr = *((int *) bytes) | htonl(value); address.s_addr = *((__be32 *) bytes) | htonl(value);
*((int *)dst) = address.s_addr; *((__be32 *)dst) = address.s_addr;
return 1; /* success */ return 1; /* success */
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment