From b59f05e781dc30d8dcae1550422c6302c766b6ad Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:01:42 +0200 Subject: [PATCH] =?UTF-8?q?vdprintf()=20=E2=86=92=20vsnprintf()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support older mac0S versiosn that lack vdprintf(). --- src/userinput.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/userinput.c b/src/userinput.c index ec19dbe2..250ece99 100644 --- a/src/userinput.c +++ b/src/userinput.c @@ -171,9 +171,22 @@ static int pinentry_exchange(int to, int from, char **retstr, const char *format, ...) { va_list ap; + char buffer[2048]; + int size; va_start(ap, format); - if (vdprintf(to, format, ap) == 0) { + + size = vsnprintf(buffer, sizeof(buffer), format, ap); + if (size < 0) { + if (retstr) + *retstr = strdup(strerror(errno)); + va_end(ap); + return -1; + } + if (size > sizeof(buffer)) + size = sizeof(buffer); + + if (write(to, buffer, size) < 0) { if (retstr) *retstr = strdup(strerror(errno)); va_end(ap);