From nobody@FreeBSD.org  Mon Oct 21 11:20:39 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id AF4A670A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Oct 2013 11:20:39 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 8ED3320A0
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Oct 2013 11:20:39 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r9LBKc1S013850
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Oct 2013 11:20:38 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r9LBKcYb013840;
	Mon, 21 Oct 2013 11:20:38 GMT
	(envelope-from nobody)
Message-Id: <201310211120.r9LBKcYb013840@oldred.freebsd.org>
Date: Mon, 21 Oct 2013 11:20:38 GMT
From: Dominic Fandrey <kamikaze@bsdforen.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Fix iconv support of mount_smbfs
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         183153
>Category:       bin
>Synopsis:       [patch] Fix iconv support of mount_smbfs(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 21 11:30:00 UTC 2013
>Closed-Date:    Thu Nov 14 09:41:33 UTC 2013
>Last-Modified:  Thu Nov 14 09:41:33 UTC 2013
>Originator:     Dominic Fandrey
>Release:        stable/10
>Organization:
private
>Environment:
FreeBSD mobileKamikaze.norad 10.0-BETA1 FreeBSD 10.0-BETA1 #0 r256685: Fri Oct 18 01:18:29 CEST 2013     root@mobileKamikaze.norad:/usr/obj/HP6510b-10/amd64/usr/src/sys/HP6510b-10  amd64

>Description:
mount_smb fails when trying to perform charset conversions with the -E argument:


mount_smbfs: Unable to load iconv library: Shared object "libiconv.so" not found, required by "mount_smbfs"
: No error: 0
mount_smbfs: can't initialize iconv support (UTF-8:850): syserr = No such file or directory
>How-To-Repeat:
mount_smbfs -E UTF-8:850 /from /to
>Fix:
The attached patch gets rid of dlopen() and uses base system iconv support instead.

Patch attached with submission follows:

Index: contrib/smbfs/lib/smb/nls.c
===================================================================
--- contrib/smbfs/lib/smb/nls.c	(revision 256833)
+++ contrib/smbfs/lib/smb/nls.c	(working copy)
@@ -36,12 +36,9 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
-#include <sys/iconv.h>
+#include <iconv.h>
 #include <sys/sysctl.h>
 #include <ctype.h>
-#ifndef APPLE
-#include <dlfcn.h>
-#endif
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
@@ -50,21 +47,10 @@
 #include <err.h>
 #include <netsmb/smb_lib.h>
 
-/*
- * prototype iconv* functions
- */
-typedef void *iconv_t;
-
-static iconv_t (*my_iconv_open)(const char *, const char *);
-static size_t(*my_iconv)(iconv_t, const char **, size_t *, char **, size_t *);
-static int(*my_iconv_close)(iconv_t);
-
 u_char nls_lower[256];
 u_char nls_upper[256];
 
 static iconv_t nls_toext, nls_toloc;
-static int iconv_loaded;
-static void *iconv_lib;
 
 int
 nls_setlocale(const char *name)
@@ -90,32 +76,18 @@
 #else
 	iconv_t icd;
 
-	if (iconv_loaded == 2)
-		return ENOENT;
-	else if (iconv_loaded == 0) {
-		iconv_loaded++;
-		iconv_lib = dlopen("libiconv.so", RTLD_LAZY | RTLD_GLOBAL);
-		if (iconv_lib == NULL) {
-			warn("Unable to load iconv library: %s\n", dlerror());
-			iconv_loaded++;
-			return ENOENT;
-		}
-		my_iconv_open = dlsym(iconv_lib, "iconv_open");
-		my_iconv = dlsym(iconv_lib, "iconv");
-		my_iconv_close = dlsym(iconv_lib, "iconv_close");
-	}
 	if (nls_toext)
-		my_iconv_close(nls_toext);
+		iconv_close(nls_toext);
 	if (nls_toloc)
-		my_iconv_close(nls_toloc);
+		iconv_close(nls_toloc);
 	nls_toext = nls_toloc = (iconv_t)0;
-	icd = my_iconv_open(external, local);
+	icd = iconv_open(external, local);
 	if (icd == (iconv_t)-1)
 		return errno;
 	nls_toext = icd;
-	icd = my_iconv_open(local, external);
+	icd = iconv_open(local, external);
 	if (icd == (iconv_t)-1) {
-		my_iconv_close(nls_toext);
+		iconv_close(nls_toext);
 		nls_toext = (iconv_t)0;
 		return errno;
 	}
@@ -130,14 +102,11 @@
 	char *p = dst;
 	size_t inlen, outlen;
 
-	if (!iconv_loaded)
-		return strcpy(dst, src);
-
 	if (nls_toloc == (iconv_t)0)
 		return strcpy(dst, src);
 	inlen = outlen = strlen(src);
-	my_iconv(nls_toloc, NULL, NULL, &p, &outlen);
-	while (my_iconv(nls_toloc, &src, &inlen, &p, &outlen) == -1) {
+	iconv(nls_toloc, NULL, NULL, &p, &outlen);
+	while (iconv(nls_toloc, &src, &inlen, &p, &outlen) == -1) {
 		*p++ = *src++;
 		inlen--;
 		outlen--;
@@ -152,14 +121,11 @@
 	char *p = dst;
 	size_t inlen, outlen;
 
-	if (!iconv_loaded)
-		return strcpy(dst, src);
-
 	if (nls_toext == (iconv_t)0)
 		return strcpy(dst, src);
 	inlen = outlen = strlen(src);
-	my_iconv(nls_toext, NULL, NULL, &p, &outlen);
-	while (my_iconv(nls_toext, &src, &inlen, &p, &outlen) == -1) {
+	iconv(nls_toext, NULL, NULL, &p, &outlen);
+	while (iconv(nls_toext, &src, &inlen, &p, &outlen) == -1) {
 		*p++ = *src++;
 		inlen--;
 		outlen--;
@@ -175,9 +141,6 @@
 	const char *s = src;
 	size_t inlen, outlen;
 
-	if (!iconv_loaded)
-		return memcpy(dst, src, size);
-
 	if (size == 0)
 		return NULL;
 
@@ -184,8 +147,8 @@
 	if (nls_toloc == (iconv_t)0)
 		return memcpy(dst, src, size);
 	inlen = outlen = size;
-	my_iconv(nls_toloc, NULL, NULL, &p, &outlen);
-	while (my_iconv(nls_toloc, &s, &inlen, &p, &outlen) == -1) {
+	iconv(nls_toloc, NULL, NULL, &p, &outlen);
+	while (iconv(nls_toloc, &s, &inlen, &p, &outlen) == -1) {
 		*p++ = *s++;
 		inlen--;
 		outlen--;
@@ -203,12 +166,12 @@
 	if (size == 0)
 		return NULL;
 
-	if (!iconv_loaded || nls_toext == (iconv_t)0)
+	if (nls_toext == (iconv_t)0)
 		return memcpy(dst, src, size);
 
 	inlen = outlen = size;
-	my_iconv(nls_toext, NULL, NULL, &p, &outlen);
-	while (my_iconv(nls_toext, &s, &inlen, &p, &outlen) == -1) {
+	iconv(nls_toext, NULL, NULL, &p, &outlen);
+	while (iconv(nls_toext, &s, &inlen, &p, &outlen) == -1) {
 		*p++ = *s++;
 		inlen--;
 		outlen--;
Index: usr.sbin/mount_smbfs/Makefile
===================================================================
--- usr.sbin/mount_smbfs/Makefile	(revision 256833)
+++ usr.sbin/mount_smbfs/Makefile	(working copy)
@@ -11,11 +11,6 @@
 LDADD=	-lsmb -lkiconv
 DPADD=	${LIBSMB} ${LIBKICONV}
 
-# Needs to be dynamically linked for optional dlopen() access to
-# userland libiconv (see the -E option).
-#
-NO_SHARED?=	NO
-
 .PATH:	${CONTRIBDIR}/mount_smbfs
 .PATH:  ${MOUNTDIR}
 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: glebius 
State-Changed-When: Sat Nov 9 14:49:13 UTC 2013 
State-Changed-Why:  
Committed, thanks! 


Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Sat Nov 9 14:49:13 UTC 2013 
Responsible-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=183153 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/183153: commit references a PR
Date: Sat,  9 Nov 2013 14:48:58 +0000 (UTC)

 Author: glebius
 Date: Sat Nov  9 14:48:50 2013
 New Revision: 257888
 URL: http://svnweb.freebsd.org/changeset/base/257888
 
 Log:
   Use system libiconv, instead of trying to dlopen() it.
   
   PR:		183153
   Submitted by:	Dominic Fandrey <kamikaze bsdforen.de>
 
 Modified:
   head/contrib/smbfs/lib/smb/nls.c
   head/usr.sbin/mount_smbfs/Makefile
 
 Modified: head/contrib/smbfs/lib/smb/nls.c
 ==============================================================================
 --- head/contrib/smbfs/lib/smb/nls.c	Sat Nov  9 14:46:24 2013	(r257887)
 +++ head/contrib/smbfs/lib/smb/nls.c	Sat Nov  9 14:48:50 2013	(r257888)
 @@ -36,12 +36,9 @@
  __FBSDID("$FreeBSD$");
  
  #include <sys/types.h>
 -#include <sys/iconv.h>
 +#include <iconv.h>
  #include <sys/sysctl.h>
  #include <ctype.h>
 -#ifndef APPLE
 -#include <dlfcn.h>
 -#endif
  #include <errno.h>
  #include <stdio.h>
  #include <string.h>
 @@ -50,21 +47,10 @@ __FBSDID("$FreeBSD$");
  #include <err.h>
  #include <netsmb/smb_lib.h>
  
 -/*
 - * prototype iconv* functions
 - */
 -typedef void *iconv_t;
 -
 -static iconv_t (*my_iconv_open)(const char *, const char *);
 -static size_t(*my_iconv)(iconv_t, const char **, size_t *, char **, size_t *);
 -static int(*my_iconv_close)(iconv_t);
 -
  u_char nls_lower[256];
  u_char nls_upper[256];
  
  static iconv_t nls_toext, nls_toloc;
 -static int iconv_loaded;
 -static void *iconv_lib;
  
  int
  nls_setlocale(const char *name)
 @@ -90,32 +76,18 @@ nls_setrecode(const char *local, const c
  #else
  	iconv_t icd;
  
 -	if (iconv_loaded == 2)
 -		return ENOENT;
 -	else if (iconv_loaded == 0) {
 -		iconv_loaded++;
 -		iconv_lib = dlopen("libiconv.so", RTLD_LAZY | RTLD_GLOBAL);
 -		if (iconv_lib == NULL) {
 -			warn("Unable to load iconv library: %s\n", dlerror());
 -			iconv_loaded++;
 -			return ENOENT;
 -		}
 -		my_iconv_open = dlsym(iconv_lib, "iconv_open");
 -		my_iconv = dlsym(iconv_lib, "iconv");
 -		my_iconv_close = dlsym(iconv_lib, "iconv_close");
 -	}
  	if (nls_toext)
 -		my_iconv_close(nls_toext);
 +		iconv_close(nls_toext);
  	if (nls_toloc)
 -		my_iconv_close(nls_toloc);
 +		iconv_close(nls_toloc);
  	nls_toext = nls_toloc = (iconv_t)0;
 -	icd = my_iconv_open(external, local);
 +	icd = iconv_open(external, local);
  	if (icd == (iconv_t)-1)
  		return errno;
  	nls_toext = icd;
 -	icd = my_iconv_open(local, external);
 +	icd = iconv_open(local, external);
  	if (icd == (iconv_t)-1) {
 -		my_iconv_close(nls_toext);
 +		iconv_close(nls_toext);
  		nls_toext = (iconv_t)0;
  		return errno;
  	}
 @@ -130,14 +102,11 @@ nls_str_toloc(char *dst, const char *src
  	char *p = dst;
  	size_t inlen, outlen;
  
 -	if (!iconv_loaded)
 -		return strcpy(dst, src);
 -
  	if (nls_toloc == (iconv_t)0)
  		return strcpy(dst, src);
  	inlen = outlen = strlen(src);
 -	my_iconv(nls_toloc, NULL, NULL, &p, &outlen);
 -	while (my_iconv(nls_toloc, &src, &inlen, &p, &outlen) == -1) {
 +	iconv(nls_toloc, NULL, NULL, &p, &outlen);
 +	while (iconv(nls_toloc, &src, &inlen, &p, &outlen) == -1) {
  		*p++ = *src++;
  		inlen--;
  		outlen--;
 @@ -152,14 +121,11 @@ nls_str_toext(char *dst, const char *src
  	char *p = dst;
  	size_t inlen, outlen;
  
 -	if (!iconv_loaded)
 -		return strcpy(dst, src);
 -
  	if (nls_toext == (iconv_t)0)
  		return strcpy(dst, src);
  	inlen = outlen = strlen(src);
 -	my_iconv(nls_toext, NULL, NULL, &p, &outlen);
 -	while (my_iconv(nls_toext, &src, &inlen, &p, &outlen) == -1) {
 +	iconv(nls_toext, NULL, NULL, &p, &outlen);
 +	while (iconv(nls_toext, &src, &inlen, &p, &outlen) == -1) {
  		*p++ = *src++;
  		inlen--;
  		outlen--;
 @@ -175,17 +141,14 @@ nls_mem_toloc(void *dst, const void *src
  	const char *s = src;
  	size_t inlen, outlen;
  
 -	if (!iconv_loaded)
 -		return memcpy(dst, src, size);
 -
  	if (size == 0)
  		return NULL;
  
  	if (nls_toloc == (iconv_t)0)
  		return memcpy(dst, src, size);
  	inlen = outlen = size;
 -	my_iconv(nls_toloc, NULL, NULL, &p, &outlen);
 -	while (my_iconv(nls_toloc, &s, &inlen, &p, &outlen) == -1) {
 +	iconv(nls_toloc, NULL, NULL, &p, &outlen);
 +	while (iconv(nls_toloc, &s, &inlen, &p, &outlen) == -1) {
  		*p++ = *s++;
  		inlen--;
  		outlen--;
 @@ -203,12 +166,12 @@ nls_mem_toext(void *dst, const void *src
  	if (size == 0)
  		return NULL;
  
 -	if (!iconv_loaded || nls_toext == (iconv_t)0)
 +	if (nls_toext == (iconv_t)0)
  		return memcpy(dst, src, size);
  
  	inlen = outlen = size;
 -	my_iconv(nls_toext, NULL, NULL, &p, &outlen);
 -	while (my_iconv(nls_toext, &s, &inlen, &p, &outlen) == -1) {
 +	iconv(nls_toext, NULL, NULL, &p, &outlen);
 +	while (iconv(nls_toext, &s, &inlen, &p, &outlen) == -1) {
  		*p++ = *s++;
  		inlen--;
  		outlen--;
 
 Modified: head/usr.sbin/mount_smbfs/Makefile
 ==============================================================================
 --- head/usr.sbin/mount_smbfs/Makefile	Sat Nov  9 14:46:24 2013	(r257887)
 +++ head/usr.sbin/mount_smbfs/Makefile	Sat Nov  9 14:48:50 2013	(r257888)
 @@ -11,11 +11,6 @@ CFLAGS+=	-DSMBFS -I${MOUNTDIR} -I${CONTR
  LDADD=	-lsmb -lkiconv
  DPADD=	${LIBSMB} ${LIBKICONV}
  
 -# Needs to be dynamically linked for optional dlopen() access to
 -# userland libiconv (see the -E option).
 -#
 -NO_SHARED?=	NO
 -
  .PATH:	${CONTRIBDIR}/mount_smbfs
  .PATH:  ${MOUNTDIR}
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/183153: commit references a PR
Date: Thu, 14 Nov 2013 09:25:38 +0000 (UTC)

 Author: glebius
 Date: Thu Nov 14 09:25:29 2013
 New Revision: 258125
 URL: http://svnweb.freebsd.org/changeset/base/258125
 
 Log:
   Merge r257888, r258049 from head:
   
     - Use system libiconv, instead of trying to dlopen() it.
     - Just disable recoding support in libsmb if built WITHOUT_ICONV.
   
   PR:		183153
   Approved by:	re (kib)
 
 Modified:
   stable/10/contrib/smbfs/lib/smb/nls.c
   stable/10/lib/libsmb/Makefile
   stable/10/usr.sbin/mount_smbfs/Makefile
 Directory Properties:
   stable/10/contrib/smbfs/   (props changed)
   stable/10/lib/libsmb/   (props changed)
   stable/10/usr.sbin/mount_smbfs/   (props changed)
 
 Modified: stable/10/contrib/smbfs/lib/smb/nls.c
 ==============================================================================
 --- stable/10/contrib/smbfs/lib/smb/nls.c	Thu Nov 14 09:22:32 2013	(r258124)
 +++ stable/10/contrib/smbfs/lib/smb/nls.c	Thu Nov 14 09:25:29 2013	(r258125)
 @@ -36,12 +36,8 @@
  __FBSDID("$FreeBSD$");
  
  #include <sys/types.h>
 -#include <sys/iconv.h>
  #include <sys/sysctl.h>
  #include <ctype.h>
 -#ifndef APPLE
 -#include <dlfcn.h>
 -#endif
  #include <errno.h>
  #include <stdio.h>
  #include <string.h>
 @@ -50,21 +46,16 @@ __FBSDID("$FreeBSD$");
  #include <err.h>
  #include <netsmb/smb_lib.h>
  
 -/*
 - * prototype iconv* functions
 - */
 -typedef void *iconv_t;
 -
 -static iconv_t (*my_iconv_open)(const char *, const char *);
 -static size_t(*my_iconv)(iconv_t, const char **, size_t *, char **, size_t *);
 -static int(*my_iconv_close)(iconv_t);
 +#ifdef HAVE_ICONV
 +#include <iconv.h>
 +#endif
  
  u_char nls_lower[256];
  u_char nls_upper[256];
  
 +#ifdef HAVE_ICONV
  static iconv_t nls_toext, nls_toloc;
 -static int iconv_loaded;
 -static void *iconv_lib;
 +#endif
  
  int
  nls_setlocale(const char *name)
 @@ -85,117 +76,107 @@ nls_setlocale(const char *name)
  int
  nls_setrecode(const char *local, const char *external)
  {
 -#ifdef APPLE
 -	return ENOENT;
 -#else
 +#ifdef HAVE_ICONV
  	iconv_t icd;
  
 -	if (iconv_loaded == 2)
 -		return ENOENT;
 -	else if (iconv_loaded == 0) {
 -		iconv_loaded++;
 -		iconv_lib = dlopen("libiconv.so", RTLD_LAZY | RTLD_GLOBAL);
 -		if (iconv_lib == NULL) {
 -			warn("Unable to load iconv library: %s\n", dlerror());
 -			iconv_loaded++;
 -			return ENOENT;
 -		}
 -		my_iconv_open = dlsym(iconv_lib, "iconv_open");
 -		my_iconv = dlsym(iconv_lib, "iconv");
 -		my_iconv_close = dlsym(iconv_lib, "iconv_close");
 -	}
  	if (nls_toext)
 -		my_iconv_close(nls_toext);
 +		iconv_close(nls_toext);
  	if (nls_toloc)
 -		my_iconv_close(nls_toloc);
 +		iconv_close(nls_toloc);
  	nls_toext = nls_toloc = (iconv_t)0;
 -	icd = my_iconv_open(external, local);
 +	icd = iconv_open(external, local);
  	if (icd == (iconv_t)-1)
  		return errno;
  	nls_toext = icd;
 -	icd = my_iconv_open(local, external);
 +	icd = iconv_open(local, external);
  	if (icd == (iconv_t)-1) {
 -		my_iconv_close(nls_toext);
 +		iconv_close(nls_toext);
  		nls_toext = (iconv_t)0;
  		return errno;
  	}
  	nls_toloc = icd;
  	return 0;
 +#else
 +	return ENOENT;
  #endif
  }
  
  char *
  nls_str_toloc(char *dst, const char *src)
  {
 +#ifdef HAVE_ICONV
  	char *p = dst;
  	size_t inlen, outlen;
  
 -	if (!iconv_loaded)
 -		return strcpy(dst, src);
 -
  	if (nls_toloc == (iconv_t)0)
  		return strcpy(dst, src);
  	inlen = outlen = strlen(src);
 -	my_iconv(nls_toloc, NULL, NULL, &p, &outlen);
 -	while (my_iconv(nls_toloc, &src, &inlen, &p, &outlen) == -1) {
 +	iconv(nls_toloc, NULL, NULL, &p, &outlen);
 +	while (iconv(nls_toloc, &src, &inlen, &p, &outlen) == -1) {
  		*p++ = *src++;
  		inlen--;
  		outlen--;
  	}
  	*p = 0;
  	return dst;
 +#else
 +	return strcpy(dst, src);
 +#endif
  }
  
  char *
  nls_str_toext(char *dst, const char *src)
  {
 +#ifdef HAVE_ICONV
  	char *p = dst;
  	size_t inlen, outlen;
  
 -	if (!iconv_loaded)
 -		return strcpy(dst, src);
 -
  	if (nls_toext == (iconv_t)0)
  		return strcpy(dst, src);
  	inlen = outlen = strlen(src);
 -	my_iconv(nls_toext, NULL, NULL, &p, &outlen);
 -	while (my_iconv(nls_toext, &src, &inlen, &p, &outlen) == -1) {
 +	iconv(nls_toext, NULL, NULL, &p, &outlen);
 +	while (iconv(nls_toext, &src, &inlen, &p, &outlen) == -1) {
  		*p++ = *src++;
  		inlen--;
  		outlen--;
  	}
  	*p = 0;
  	return dst;
 +#else
 +	return strcpy(dst, src);
 +#endif
  }
  
  void *
  nls_mem_toloc(void *dst, const void *src, int size)
  {
 +#ifdef HAVE_ICONV
  	char *p = dst;
  	const char *s = src;
  	size_t inlen, outlen;
  
 -	if (!iconv_loaded)
 -		return memcpy(dst, src, size);
 -
  	if (size == 0)
  		return NULL;
  
  	if (nls_toloc == (iconv_t)0)
  		return memcpy(dst, src, size);
  	inlen = outlen = size;
 -	my_iconv(nls_toloc, NULL, NULL, &p, &outlen);
 -	while (my_iconv(nls_toloc, &s, &inlen, &p, &outlen) == -1) {
 +	iconv(nls_toloc, NULL, NULL, &p, &outlen);
 +	while (iconv(nls_toloc, &s, &inlen, &p, &outlen) == -1) {
  		*p++ = *s++;
  		inlen--;
  		outlen--;
  	}
  	return dst;
 +#else
 +	return memcpy(dst, src, size);
 +#endif
  }
  
  void *
  nls_mem_toext(void *dst, const void *src, int size)
  {
 +#ifdef HAVE_ICONV
  	char *p = dst;
  	const char *s = src;
  	size_t inlen, outlen;
 @@ -203,17 +184,20 @@ nls_mem_toext(void *dst, const void *src
  	if (size == 0)
  		return NULL;
  
 -	if (!iconv_loaded || nls_toext == (iconv_t)0)
 +	if (nls_toext == (iconv_t)0)
  		return memcpy(dst, src, size);
  
  	inlen = outlen = size;
 -	my_iconv(nls_toext, NULL, NULL, &p, &outlen);
 -	while (my_iconv(nls_toext, &s, &inlen, &p, &outlen) == -1) {
 +	iconv(nls_toext, NULL, NULL, &p, &outlen);
 +	while (iconv(nls_toext, &s, &inlen, &p, &outlen) == -1) {
  		*p++ = *s++;
  		inlen--;
  		outlen--;
  	}
  	return dst;
 +#else
 +	return memcpy(dst, src, size);
 +#endif
  }
  
  char *
 
 Modified: stable/10/lib/libsmb/Makefile
 ==============================================================================
 --- stable/10/lib/libsmb/Makefile	Thu Nov 14 09:22:32 2013	(r258124)
 +++ stable/10/lib/libsmb/Makefile	Thu Nov 14 09:25:29 2013	(r258125)
 @@ -1,5 +1,7 @@
  # $FreeBSD$
  
 +.include <bsd.own.mk>
 +
  CONTRIBDIR=	${.CURDIR}/../../contrib/smbfs
  .PATH: ${CONTRIBDIR}/lib/smb
  
 @@ -16,4 +18,8 @@ SRCS=	rcfile.c ctx.c cfopt.c subr.c nls.
  WARNS?=	1
  CFLAGS+= -DSMB_CFG_FILE=\"/etc/nsmb.conf\" -I${CONTRIBDIR}/include
  
 +.if ${MK_ICONV} != "no"
 +CFLAGS+= -DHAVE_ICONV=1
 +.endif
 +
  .include <bsd.lib.mk>
 
 Modified: stable/10/usr.sbin/mount_smbfs/Makefile
 ==============================================================================
 --- stable/10/usr.sbin/mount_smbfs/Makefile	Thu Nov 14 09:22:32 2013	(r258124)
 +++ stable/10/usr.sbin/mount_smbfs/Makefile	Thu Nov 14 09:25:29 2013	(r258125)
 @@ -11,11 +11,6 @@ CFLAGS+=	-DSMBFS -I${MOUNTDIR} -I${CONTR
  LDADD=	-lsmb -lkiconv
  DPADD=	${LIBSMB} ${LIBKICONV}
  
 -# Needs to be dynamically linked for optional dlopen() access to
 -# userland libiconv (see the -E option).
 -#
 -NO_SHARED?=	NO
 -
  .PATH:	${CONTRIBDIR}/mount_smbfs
  .PATH:  ${MOUNTDIR}
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: glebius 
State-Changed-When: Thu Nov 14 09:41:21 UTC 2013 
State-Changed-Why:  
Merged to stable/10. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=183153 
>Unformatted:
