Subject: lib: in ykpiv_transfer_data() handle overflow by exiting

this is detected and printed, but we never exit the function

Thanks to Eric Sesterhenn of x41 D-Sec for reporting this issue to us.
---
 lib/ykpiv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/ykpiv.c b/lib/ykpiv.c
index 96a5a90..b5fdcbb 100644
Origin: vendor
Bug: 906128
From: Klas Lindfors <klas@yubico.com>
Reviewed-by: Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
Last-Update: 2018-08-14
Applied-Upstream: 01a127a44a2229ea14195208e444ec526eaf45f4

--- a/lib/ykpiv.c
+++ b/lib/ykpiv.c
@@ -317,7 +317,10 @@ ykpiv_rc ykpiv_transfer_data(ykpiv_state *state, const unsigned char *templ,
       return YKPIV_OK;
     }
     if(*out_len + recv_len - 2 > max_out) {
-      fprintf(stderr, "Output buffer to small, wanted to write %lu, max was %lu.", *out_len + recv_len - 2, max_out);
+      if(state->verbose) {
+        fprintf(stderr, "Output buffer to small, wanted to write %lu, max was %lu.", *out_len + recv_len - 2, max_out);
+      }
+      return YKPIV_SIZE_ERROR;
     }
     if(out_data) {
       memcpy(out_data, data, recv_len - 2);
