Page MenuHomeFreeBSD

Avoid unaligned memory accesses when encoding netbios names in mount_smbfs
ClosedPublic

Authored by ian on Dec 19 2015, 12:42 AM.
Tags
None
Referenced Files
F132396188: D4622.diff
Thu, Oct 16, 1:49 PM
Unknown Object (File)
Tue, Oct 14, 3:10 AM
Unknown Object (File)
Sun, Oct 12, 7:36 AM
Unknown Object (File)
Thu, Oct 9, 10:27 PM
Unknown Object (File)
Thu, Oct 9, 4:47 AM
Unknown Object (File)
Sep 12 2025, 8:12 PM
Unknown Object (File)
Sep 9 2025, 7:31 PM
Unknown Object (File)
Jul 25 2025, 3:16 AM
Subscribers

Details

Summary

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.

Related PRs:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=180438
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=189415

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ian retitled this revision from to Avoid unaligned memory accesses when encoding netbios names in mount_smbfs.
ian updated this object.
ian edited the test plan for this revision. (Show Details)
ian set the repository for this revision to rS FreeBSD src repository - subversion.
imp added a reviewer: imp.

Looks good to me. Less obscure than what we're doing now.

This revision is now accepted and ready to land.Dec 21 2015, 3:48 PM
This revision was automatically updated to reflect the committed changes.