From cd7975662edec15b761d61b49e30e043c78c48a0 Mon Sep 17 00:00:00 2001 From: jdolecek Date: Fri, 28 Mar 2003 13:08:00 +0000 Subject: [PATCH] memsetw(): fix mistake where the 'word' value would get written byteswapped on i386, resulting in ' ' being encoded incorrectly in session setup query - just use memcpy() as rest of code, it DTRT for both LE and BE machines in this case, since the function is called with 'word' in little-endian format Many thanks to Martin Husemann for testing on i386 and sparc64 against both w2k and Samba. --- dist/smbfs/lib/smb/nb_name.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dist/smbfs/lib/smb/nb_name.c b/dist/smbfs/lib/smb/nb_name.c index cf7b2b411a38..49a6231ab856 100644 --- a/dist/smbfs/lib/smb/nb_name.c +++ b/dist/smbfs/lib/smb/nb_name.c @@ -145,12 +145,8 @@ nb_encname_len(const char *str) static void memsetw(char *dst, int n, u_short word) { - unsigned char c2 = word & 0x00ff; - unsigned char c1 = (word>>8) & 0x00ff; - while (n--) { - *dst++ = c1; - *dst++ = c2; - } + for(; n > 0; n--, dst += 2) + memcpy(dst, &word, 2); } int