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
Unknown Object (File)
Sun, Jun 2, 4:10 PM
Unknown Object (File)
Apr 27 2024, 12:09 PM
Unknown Object (File)
Apr 27 2024, 12:09 PM
Unknown Object (File)
Apr 27 2024, 12:09 PM
Unknown Object (File)
Apr 22 2024, 8:36 PM
Unknown Object (File)
Feb 13 2024, 10:05 PM
Unknown Object (File)
Jan 28 2024, 6:57 PM
Unknown Object (File)
Jan 28 2024, 6:51 PM
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.