]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Avoid unaligned memory accesses when encoding netbios names in libsmb.
authorian <ian@FreeBSD.org>
Mon, 21 Dec 2015 17:17:00 +0000 (17:17 +0000)
committerian <ian@FreeBSD.org>
Mon, 21 Dec 2015 17:17:00 +0000 (17:17 +0000)
commit1a16baceaae6c0428099af41b18d01eebc56f62b
treea2a580e85aa980e5154f8536ccf853fde8b151e8
parente93f3f0c71917233d6e21e3fd05e1520d2d84984
Avoid unaligned memory accesses when encoding netbios names in libsmb.

The current code for encoding a netbios name converts each byte to a 16-bit
value and stores the result by casting a char* to u_short*, resulting in
alignment faults on strict-alignment platforms.

This change reimplements the encoding routine using only byte accesses to
memory. There is no particular reason to work with 16-bit values just
because the encoding process creates two bytes of output for every byte of
input. Working a byte at at time also avoids endian problems for big-endian
platforms.

PR: 180438
PR: 189415
Differential Revision: https://reviews.freebsd.org/D4622
contrib/smbfs/lib/smb/nb_name.c