Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Sep 2017 16:30:50 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324103 - head/lib/libc/locale
Message-ID:  <201709291630.v8TGUo8N038154@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Fri Sep 29 16:30:50 2017
New Revision: 324103
URL: https://svnweb.freebsd.org/changeset/base/324103

Log:
  __setrunelocale: Fix asprintf(3) failure not returning an error.
  
  Also fix the style of the asprintf(3) call in __collate_load_tables_l().
  Both of these lines were modified away from snprintf(3) during the
  import from DragonFly/Illumos.
  
  Reviewed by:	jilles (briefly over shoulder)
  MFC after:	2 weeks
  Sponsored by:	Dell EMC Isilon

Modified:
  head/lib/libc/locale/collate.c
  head/lib/libc/locale/setrunelocale.c

Modified: head/lib/libc/locale/collate.c
==============================================================================
--- head/lib/libc/locale/collate.c	Fri Sep 29 15:53:26 2017	(r324102)
+++ head/lib/libc/locale/collate.c	Fri Sep 29 16:30:50 2017	(r324103)
@@ -125,8 +125,7 @@ __collate_load_tables_l(const char *encoding, struct x
 		return (_LDP_CACHE);
 	}
 
-	asprintf(&buf, "%s/%s/LC_COLLATE", _PathLocale, encoding);
-	if (buf == NULL)
+	if (asprintf(&buf, "%s/%s/LC_COLLATE", _PathLocale, encoding) == -1)
 		return (_LDP_ERROR);
 
 	if ((fd = _open(buf, O_RDONLY)) < 0) {

Modified: head/lib/libc/locale/setrunelocale.c
==============================================================================
--- head/lib/libc/locale/setrunelocale.c	Fri Sep 29 15:53:26 2017	(r324102)
+++ head/lib/libc/locale/setrunelocale.c	Fri Sep 29 16:30:50 2017	(r324103)
@@ -110,9 +110,8 @@ __setrunelocale(struct xlocale_ctype *l, const char *e
 	}
 
 	/* Range checking not needed, encoding length already checked before */
-	asprintf(&path, "%s/%s/LC_CTYPE", _PathLocale, encoding);
-	if (path == NULL)
-		return (0);
+	if (asprintf(&path, "%s/%s/LC_CTYPE", _PathLocale, encoding) == -1)
+		return (errno);
 
 	if ((rl = _Read_RuneMagi(path)) == NULL) {
 		free(path);



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