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)
connected to port 139 (the NACK is
since we do not begin with RFC1001
session initialize frame) */
server->addr.sockAddr.sin_port = CIFS_PORT;
server->addr.sockAddr.sin_port = htons(CIFS_PORT);
cifs_reconnect(server);
csocket = server->ssocket;
wake_up(&server->response_q);
......@@ -849,7 +849,7 @@ cifs_find_tcp_session(struct in_addr * target_ip_addr,
}
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 cifsTconInfo *tcon;
......@@ -968,7 +968,7 @@ ipv4_connect(struct sockaddr_in *psin_server, struct socket **csocket,
{
int rc = 0;
int connected = 0;
unsigned short int orig_port = 0;
__be16 orig_port = 0;
if(*csocket == NULL) {
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)
{
int rc = 0;
int connected = 0;
unsigned short int orig_port = 0;
__be16 orig_port = 0;
if(*csocket == NULL) {
rc = sock_create_kern(PF_INET6, SOCK_STREAM, IPPROTO_TCP, csocket);
......
......@@ -315,12 +315,12 @@ checkSMBhdr(struct smb_hdr *smb, __u16 mid)
int
checkSMB(struct smb_hdr *smb, __u16 mid, int length)
{
__u32 len = be32_to_cpu(smb->smb_buf_length);
cFYI(0,
("Entering checkSMB with Length: %x, smb_buf_length: %x ",
length, ntohl(smb->smb_buf_length)));
if (((unsigned int)length < 2 + sizeof (struct smb_hdr))
|| (ntohl(smb->smb_buf_length) >
CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)) {
length, len));
if (((unsigned int)length < 2 + sizeof (struct smb_hdr)) ||
(len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)) {
if ((unsigned int)length < 2 + sizeof (struct smb_hdr)) {
cERROR(1, ("Length less than 2 + sizeof smb_hdr "));
if (((unsigned int)length >= sizeof (struct smb_hdr) - 1)
......@@ -328,8 +328,7 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length)
return 0; /* some error cases do not return wct and bcc */
}
if (ntohl(smb->smb_buf_length) >
CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)
if (len > CIFS_MAX_MSGSIZE + MAX_CIFS_HDR_SIZE - 4)
cERROR(1,
("smb_buf_length greater than CIFS_MAX_MSGSIZE ... "));
cERROR(1,
......@@ -341,8 +340,8 @@ checkSMB(struct smb_hdr *smb, __u16 mid, int length)
if (checkSMBhdr(smb, mid))
return 1;
if ((4 + ntohl(smb->smb_buf_length) != smbCalcSize(smb))
|| (4 + ntohl(smb->smb_buf_length) != (unsigned int)length)) {
if ((4 + len != smbCalcSize(smb))
|| (4 + len != (unsigned int)length)) {
return 0;
} else {
cERROR(1, ("smbCalcSize %x ", smbCalcSize(smb)));
......
......@@ -187,8 +187,8 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
if (value > addr_class_max[end - bytes])
return 0;
address.s_addr = *((int *) bytes) | htonl(value);
*((int *)dst) = address.s_addr;
address.s_addr = *((__be32 *) bytes) | htonl(value);
*((__be32 *)dst) = address.s_addr;
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