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
F174540793: D4622.id11427.diff
Sun, Oct 4, 1:10 AM
F174530359: D4622.id11529.diff
Sat, Oct 3, 11:22 PM
F174529235: D4622.diff
Sat, Oct 3, 11:09 PM
Unknown Object (File)
Wed, Sep 30, 2:12 PM
Unknown Object (File)
Mon, Sep 21, 11:19 AM
Unknown Object (File)
Sun, Sep 20, 9:56 PM
Unknown Object (File)
Sun, Sep 20, 6:23 PM
Unknown Object (File)
Sat, Sep 19, 10:48 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.