]> granicus.if.org Git - curl/commitdiff
smb: Use endian functions for reading length and offset values
authorSteve Holme <steve_holme@hotmail.com>
Wed, 31 Dec 2014 16:07:32 +0000 (16:07 +0000)
committerSteve Holme <steve_holme@hotmail.com>
Wed, 31 Dec 2014 16:52:12 +0000 (16:52 +0000)
lib/smb.c

index 783544405f6712e3fc2f39593fe76712ccfc4b6a..0286959328bffb3b14a9e1a41e1a2b53d8776dd8 100644 (file)
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -45,6 +45,7 @@
 #include "curl_ntlm_core.h"
 #include "curl_memory.h"
 #include "escape.h"
+#include "curl_endian.h"
 
 /* The last #include file should be: */
 #include "memdebug.h"
@@ -776,10 +777,8 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
       next_state = SMB_CLOSE;
       break;
     }
-    len = smb_swap16(*(unsigned short *)((char *)msg +
-                     sizeof(struct smb_header) + 11));
-    off = smb_swap16(*(unsigned short *)((char *)msg +
-                     sizeof(struct smb_header) + 13));
+    len = Curl_read16_le(((char *) msg) + sizeof(struct smb_header) + 11);
+    off = Curl_read16_le(((char *) msg) + sizeof(struct smb_header) + 13);
     if(len > 0) {
       result = Curl_client_write(conn, CLIENTWRITE_BODY,
                                  (char *)msg + off + sizeof(unsigned int),
@@ -802,8 +801,7 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
       next_state = SMB_CLOSE;
       break;
     }
-    len = smb_swap16(*(unsigned short *)((char *)msg +
-                     sizeof(struct smb_header) + 5));
+    len = Curl_read16_le(((char *) msg) + sizeof(struct smb_header) + 5);
     conn->data->req.bytecount += len;
     conn->data->req.offset += len;
     Curl_pgrsSetUploadCounter(conn->data, conn->data->req.bytecount);