Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Jan 2016 23:36:49 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r294364 - in stable/10: contrib/smbfs/lib/smb lib usr.sbin
Message-ID:  <201601192336.u0JNanUg081127@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Tue Jan 19 23:36:49 2016
New Revision: 294364
URL: https://svnweb.freebsd.org/changeset/base/294364

Log:
  MFC r292337, r292552, r292553:
  
    Build mount_smbfs for arm.  Also sort the subdirs.
  
    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.
  
    Make the building of libsmb and mount_smbfs unconditional, now that r292552
    has eliminated alignment and endian problems that were making it fail on
    some platforms.
  
  PR:           180438
  PR:           189415
  Relnotes:	Yes

Modified:
  stable/10/contrib/smbfs/lib/smb/nb_name.c
  stable/10/lib/Makefile
  stable/10/usr.sbin/Makefile
  stable/10/usr.sbin/Makefile.amd64
  stable/10/usr.sbin/Makefile.arm
  stable/10/usr.sbin/Makefile.i386
  stable/10/usr.sbin/Makefile.ia64
  stable/10/usr.sbin/Makefile.powerpc
  stable/10/usr.sbin/Makefile.sparc64
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/smbfs/lib/smb/nb_name.c
==============================================================================
--- stable/10/contrib/smbfs/lib/smb/nb_name.c	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/contrib/smbfs/lib/smb/nb_name.c	Tue Jan 19 23:36:49 2016	(r294364)
@@ -143,15 +143,13 @@ nb_encname_len(const char *str)
 	return len;
 }
 
-#define	NBENCODE(c)	(htole16((u_short)(((u_char)(c) >> 4) | \
-			 (((u_char)(c) & 0xf) << 8)) + 0x4141))
-
-static void
-memsetw(char *dst, int n, u_short word)
+static inline void
+nb_char_encode(u_char **ptr, u_char c, int n)
 {
+
 	while (n--) {
-		*(u_short*)dst = word;
-		dst += 2;
+		*(*ptr)++ = 0x41 + (c >> 4);
+		*(*ptr)++ = 0x41 + (c & 0x0f);
 	}
 }
 
@@ -165,19 +163,15 @@ nb_name_encode(struct nb_name *np, u_cha
 	*cp++ = NB_ENCNAMELEN;
 	name = np->nn_name;
 	if (name[0] == '*' && name[1] == 0) {
-		*(u_short*)cp = NBENCODE('*');
-		memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' '));
-		cp += NB_ENCNAMELEN;
+		nb_char_encode(&cp, '*', 1);
+		nb_char_encode(&cp, ' ', NB_NAMELEN - 1);
 	} else {
-		for (i = 0; *name && i < NB_NAMELEN - 1; i++, cp += 2, name++)
-			*(u_short*)cp = NBENCODE(toupper(*name));
-		i = NB_NAMELEN - i - 1;
-		if (i > 0) {
-			memsetw(cp, i, NBENCODE(' '));
-			cp += i * 2;
-		}
-		*(u_short*)cp = NBENCODE(np->nn_type);
-		cp += 2;
+		for (i = 0; i < NB_NAMELEN - 1; i++)
+			if (*name != 0)
+				nb_char_encode(&cp, toupper(*name++), 1);
+			else
+				nb_char_encode(&cp, ' ', 1);
+		nb_char_encode(&cp, np->nn_type, 1);
 	}
 	*cp = 0;
 	if (np->nn_scope == NULL)

Modified: stable/10/lib/Makefile
==============================================================================
--- stable/10/lib/Makefile	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/lib/Makefile	Tue Jan 19 23:36:49 2016	(r294364)
@@ -84,7 +84,7 @@ SUBDIR=	${SUBDIR_ORDERED} \
 	libsbuf \
 	${_libsdp} \
 	${_libsm} \
-	${_libsmb} \
+	libsmb \
 	${_libsmdb} \
 	${_libsmutil} \
 	libstand \
@@ -214,7 +214,6 @@ _libypclnt=	libypclnt
 .endif
 
 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
-_libsmb=	libsmb
 _libvgl=	libvgl
 _libproc=	libproc
 _librtld_db=	librtld_db
@@ -228,7 +227,6 @@ _libvmmapi=	libvmmapi
 
 .if ${MACHINE_CPUARCH} == "ia64"
 _libefi=	libefi
-_libsmb=	libsmb
 .endif
 
 .if ${MACHINE_CPUARCH} == "mips"
@@ -239,11 +237,6 @@ _librtld_db=	librtld_db
 .if ${MACHINE_CPUARCH} == "powerpc"
 _libproc=	libproc
 _librtld_db=	librtld_db
-_libsmb=	libsmb
-.endif
-
-.if ${MACHINE_CPUARCH} == "sparc64"
-_libsmb=	libsmb
 .endif
 
 .if ${MK_OPENSSL} != "no"

Modified: stable/10/usr.sbin/Makefile
==============================================================================
--- stable/10/usr.sbin/Makefile	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/usr.sbin/Makefile	Tue Jan 19 23:36:49 2016	(r294364)
@@ -44,6 +44,7 @@ SUBDIR=	adduser \
 	mixer \
 	mlxcontrol \
 	mountd \
+	mount_smbfs \
 	mptutil \
 	mtest \
 	${_mtree} \

Modified: stable/10/usr.sbin/Makefile.amd64
==============================================================================
--- stable/10/usr.sbin/Makefile.amd64	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/usr.sbin/Makefile.amd64	Tue Jan 19 23:36:49 2016	(r294364)
@@ -25,7 +25,6 @@ SUBDIR+=	hyperv
 .endif
 SUBDIR+=	kgmon
 SUBDIR+=	lptcontrol
-SUBDIR+=	mount_smbfs
 SUBDIR+=	mptable
 .if ${MK_NDIS} != "no"
 SUBDIR+=	ndiscvt

Modified: stable/10/usr.sbin/Makefile.arm
==============================================================================
--- stable/10/usr.sbin/Makefile.arm	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/usr.sbin/Makefile.arm	Tue Jan 19 23:36:49 2016	(r294364)
@@ -1,4 +1,4 @@
 # $FreeBSD$
 
-SUBDIR+=	ofwdump
 SUBDIR+=	kgmon
+SUBDIR+=	ofwdump

Modified: stable/10/usr.sbin/Makefile.i386
==============================================================================
--- stable/10/usr.sbin/Makefile.i386	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/usr.sbin/Makefile.i386	Tue Jan 19 23:36:49 2016	(r294364)
@@ -15,7 +15,6 @@ SUBDIR+=	hyperv
 SUBDIR+=	kgmon
 SUBDIR+=	kgzip
 SUBDIR+=	lptcontrol
-SUBDIR+=	mount_smbfs
 SUBDIR+=	mptable
 .if ${MK_NDIS} != "no"
 SUBDIR+=	ndiscvt

Modified: stable/10/usr.sbin/Makefile.ia64
==============================================================================
--- stable/10/usr.sbin/Makefile.ia64	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/usr.sbin/Makefile.ia64	Tue Jan 19 23:36:49 2016	(r294364)
@@ -4,6 +4,5 @@
 SUBDIR+=	acpi
 .endif
 SUBDIR+=	kgmon
-SUBDIR+=	mount_smbfs
 SUBDIR:=	${SUBDIR:Nuathload}
 SUBDIR+=	zzz

Modified: stable/10/usr.sbin/Makefile.powerpc
==============================================================================
--- stable/10/usr.sbin/Makefile.powerpc	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/usr.sbin/Makefile.powerpc	Tue Jan 19 23:36:49 2016	(r294364)
@@ -1,5 +1,4 @@
 # $FreeBSD$
 
-SUBDIR+=	mount_smbfs
 SUBDIR+=	nvram
 SUBDIR+=	ofwdump

Modified: stable/10/usr.sbin/Makefile.sparc64
==============================================================================
--- stable/10/usr.sbin/Makefile.sparc64	Tue Jan 19 23:35:12 2016	(r294363)
+++ stable/10/usr.sbin/Makefile.sparc64	Tue Jan 19 23:36:49 2016	(r294364)
@@ -1,5 +1,4 @@
 # $FreeBSD$
 
 SUBDIR+=	eeprom
-SUBDIR+=	mount_smbfs
 SUBDIR+=	ofwdump



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601192336.u0JNanUg081127>