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);