about summary refs log tree commit diff
path: root/include/programs
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@redhat.com>2020-01-08 13:24:42 -0500
committerCarlos O'Donell <carlos@redhat.com>2020-04-26 13:55:58 -0400
commit92954ffa5a5662fbfde14febd7e5dcc358c85470 (patch)
treeea7eb81874f0b3d706e701eda47f29718f7d948f /include/programs
parent8d9ffbb9d00669f62d5ddb4283b7c3d03955d942 (diff)
downloadglibc-92954ffa5a5662fbfde14febd7e5dcc358c85470.tar.gz
glibc-92954ffa5a5662fbfde14febd7e5dcc358c85470.tar.xz
glibc-92954ffa5a5662fbfde14febd7e5dcc358c85470.zip
localedef: Add verbose messages for failure paths.
During testing of localedef running in a minimal container
there were several error cases which were hard to diagnose
since they appeared as strerror (errno) values printed by the
higher level functions.  This change adds three new verbose
messages for potential failure paths.  The new messages give
the user the opportunity to use -v and display additional
information about why localedef might be failing.  I found
these messages useful myself while writing a localedef
container test for --no-hard-links.

Since the changes cleanup the code that handle codeset
normalization we add tst-localedef-path-norm which contains
many sub-tests to verify the correct expected normalization of
codeset strings both when installing to default paths (the
only time normalization is enabled) and installing to absolute
paths.  During the refactoring I created at least one
buffer-overflow which valgrind caught, but these tests did not
catch because the exec in the container had a very clean heap
with zero-initialized memory. However, between valgrind and
the tests the results are clean.

The new tst-localedef-path-norm passes without regression on
x86_64.

Change-Id: I28b9f680711ff00252a2cb15625b774cc58ecb9d
Diffstat (limited to 'include/programs')
-rw-r--r--include/programs/xasprintf.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/programs/xasprintf.h b/include/programs/xasprintf.h
new file mode 100644
index 0000000000..53193ba383
--- /dev/null
+++ b/include/programs/xasprintf.h
@@ -0,0 +1,24 @@
+/* asprintf with out of memory checking
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published
+   by the Free Software Foundation; version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
+
+#ifndef _XASPRINTF_H
+#define _XASPRINTF_H	1
+
+extern char *xasprintf (const char *format, ...)
+    __attribute__ ((__format__ (__printf__, 1, 2), __warn_unused_result__));
+
+#endif /* xasprintf.h */