Skip to content

Commit

Permalink
vdprintf() → vsnprintf()
Browse files Browse the repository at this point in the history
Support older mac0S versiosn that lack vdprintf().
  • Loading branch information
DimitriPapadopoulos committed Jun 3, 2024
1 parent 371edb5 commit b59f05e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/userinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b59f05e

Please sign in to comment.