mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
assert: Remove the use of %n from __assert_fail_base (BZ #32456)
The require size for mmap can be inferred from __vasprintf return value. It also fixes tst-assert-2 when building with --enable-fortify, where even if the format is not translated, __readonly_area fails because malloc can not be used. Checked on aarch64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
@@ -32,7 +32,7 @@ __assert_perror_fail (int errnum,
|
|||||||
char errbuf[1024];
|
char errbuf[1024];
|
||||||
|
|
||||||
char *e = __strerror_r (errnum, errbuf, sizeof errbuf);
|
char *e = __strerror_r (errnum, errbuf, sizeof errbuf);
|
||||||
__assert_fail_base (_("%s%s%s:%u: %s%sUnexpected error: %s.\n%n"),
|
__assert_fail_base (_("%s%s%s:%u: %s%sUnexpected error: %s.\n"),
|
||||||
e, file, line, function);
|
e, file, line, function);
|
||||||
}
|
}
|
||||||
libc_hidden_def (__assert_perror_fail)
|
libc_hidden_def (__assert_perror_fail)
|
||||||
|
@@ -15,24 +15,17 @@
|
|||||||
License along with the GNU C Library; if not, see
|
License along with the GNU C Library; if not, see
|
||||||
<https://www.gnu.org/licenses/>. */
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <assert.h>
|
#include <intprops.h>
|
||||||
#include <atomic.h>
|
|
||||||
#include <ldsodefs.h>
|
#include <ldsodefs.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <stdio.h>
|
#include <libio/iolibio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sysdep.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <setvmaname.h>
|
#include <setvmaname.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <intprops.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
extern const char *__progname;
|
extern const char *__progname;
|
||||||
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <libio/iolibio.h>
|
|
||||||
#define fflush(s) _IO_fflush (s)
|
#define fflush(s) _IO_fflush (s)
|
||||||
|
|
||||||
/* This function, when passed a string containing an asserted
|
/* This function, when passed a string containing an asserted
|
||||||
@@ -56,12 +49,12 @@ __assert_fail_base (const char *fmt, const char *assertion, const char *file,
|
|||||||
FATAL_PREPARE;
|
FATAL_PREPARE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int total;
|
int total = __asprintf (&str, fmt,
|
||||||
if (__asprintf (&str, fmt,
|
|
||||||
__progname, __progname[0] ? ": " : "",
|
__progname, __progname[0] ? ": " : "",
|
||||||
file, line,
|
file, line,
|
||||||
function ? function : "", function ? ": " : "",
|
function ? function : "", function ? ": " : "",
|
||||||
assertion, &total) >= 0)
|
assertion);
|
||||||
|
if (total >= 0)
|
||||||
{
|
{
|
||||||
/* Print the message. */
|
/* Print the message. */
|
||||||
(void) __fxprintf (NULL, "%s", str);
|
(void) __fxprintf (NULL, "%s", str);
|
||||||
@@ -129,6 +122,6 @@ void
|
|||||||
__assert_fail (const char *assertion, const char *file, unsigned int line,
|
__assert_fail (const char *assertion, const char *file, unsigned int line,
|
||||||
const char *function)
|
const char *function)
|
||||||
{
|
{
|
||||||
__assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n%n"),
|
__assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n"),
|
||||||
assertion, file, line, function);
|
assertion, file, line, function);
|
||||||
}
|
}
|
||||||
|
12
po/libc.pot
12
po/libc.pot
@@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: libc 2.40.9000\n"
|
"Project-Id-Version: libc 2.40.9000\n"
|
||||||
"POT-Creation-Date: 2024-12-30 16:29-0300\n"
|
"POT-Creation-Date: 2024-12-30 16:34-0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@@ -102,16 +102,12 @@ msgstr ""
|
|||||||
|
|
||||||
#: assert/assert-perr.c:35
|
#: assert/assert-perr.c:35
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid ""
|
msgid "%s%s%s:%u: %s%sUnexpected error: %s.\n"
|
||||||
"%s%s%s:%u: %s%sUnexpected error: %s.\n"
|
|
||||||
"%n"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: assert/assert.c:132
|
#: assert/assert.c:125
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid ""
|
msgid "%s%s%s:%u: %s%sAssertion `%s' failed.\n"
|
||||||
"%s%s%s:%u: %s%sAssertion `%s' failed.\n"
|
|
||||||
"%n"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: catgets/gencat.c:111
|
#: catgets/gencat.c:111
|
||||||
|
Reference in New Issue
Block a user