Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdprintf() → vsnprintf() #1229

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ write \
], [], AC_MSG_ERROR([Required function not found]))

# Checks for optional functions.
AC_CHECK_FUNCS([pthread_mutexattr_setrobust])
AC_CHECK_FUNCS([ \
pthread_mutexattr_setrobust \
vdprintf \
])

# Use PKG_CHECK_MODULES compiler/linker flags
save_openssl_CPPFLAGS="${CPPFLAGS}"
save_openssl_LIBS="${LIBS}"
Expand Down
16 changes: 16 additions & 0 deletions src/userinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ static int pinentry_read(int from, char **retstr)
return -1;
}

#ifndef HAVE_VDPRINTF
static int vdprintf(int fd, const char *format, va_list ap)
{
char buffer[2049];
int size = vsnprintf(buffer, sizeof(buffer), format, ap);

if (size < 0)
return size;

if (size >= sizeof(buffer)) // silently discard beyond the buffer size
size = sizeof(buffer) - 1;

return (int) write(fd, buffer, size);
}
#endif

static int pinentry_exchange(int to, int from, char **retstr,
const char *format, ...)
{
Expand Down