public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: binutils@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 2/3] Do not call fputc from _bfd_doprnt
Date: Mon, 29 Jan 2024 18:03:32 -0700	[thread overview]
Message-ID: <20240130010540.1754740-3-tom@tromey.com> (raw)
In-Reply-To: <20240130010540.1754740-1-tom@tromey.com>

I noticed that _bfd_doprnt can unconditionally call fputc.  However,
when called from error_handler_sprintf, this will likely result in a
crash, as the stream argument does not actually point to a FILE.

bfd/ChangeLog
2024-01-29  Tom Tromey  <tom@tromey.com>

	* bfd.c (_bfd_doprnt): Do not call fputc.
---
 bfd/ChangeLog | 4 ++++
 bfd/bfd.c     | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/bfd/bfd.c b/bfd/bfd.c
index 5619799e403..0f1eaa1629f 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1027,7 +1027,7 @@ _bfd_doprnt (print_func print, void *stream, const char *format,
 	}
       else if (ptr[1] == '%')
 	{
-	  fputc ('%', stream);
+	  print (stream, "%%");
 	  result = 1;
 	  ptr += 2;
 	}
-- 
2.43.0


  parent reply	other threads:[~2024-01-30  1:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30  1:03 [PATCH 0/3] Fix some error-printing issues Tom Tromey
2024-01-30  1:03 ` [PATCH 1/3] Make several more BFD globals thread-local Tom Tromey
2024-02-12 15:28   ` Nick Clifton
2024-02-12 23:52     ` Tom Tromey
2024-02-13  0:35     ` Tom Tromey
2024-02-13  1:20       ` Tom Tromey
2024-03-09  1:12         ` Tom Tromey
2024-03-09  4:11           ` Alan Modra
2024-03-09 10:31             ` Alan Modra
2024-03-15  0:12               ` Tom Tromey
2024-03-19 20:17                 ` Tom Tromey
2024-03-15  1:15             ` Tom Tromey
2024-01-30  1:03 ` Tom Tromey [this message]
2024-02-12 15:04   ` [PATCH 2/3] Do not call fputc from _bfd_doprnt Nick Clifton
2024-01-30  1:03 ` [PATCH 3/3] Introduce bfd_print_error function Tom Tromey
2024-02-12 15:04   ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240130010540.1754740-3-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).