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
F135827223: D4622.id11427.diff
Thu, Nov 13, 6:50 AM
F135827207: D4622.id.diff
Thu, Nov 13, 6:49 AM
F135808973: D4622.id11427.diff
Thu, Nov 13, 2:24 AM
F135808960: D4622.id11529.diff
Thu, Nov 13, 2:23 AM
F135791009: D4622.diff
Wed, Nov 12, 10:07 PM
Unknown Object (File)
Tue, Oct 28, 2:12 PM
Unknown Object (File)
Thu, Oct 16, 1:49 PM
Unknown Object (File)
Oct 14 2025, 3:10 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 Skipped
Unit
Tests Skipped

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.