From 43ffb65462e8f1bd5a5a1aacec2c1358483ab462 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Thu, 9 Jul 2015 10:28:21 +0200 Subject: [PATCH] don't do memcpy with NULL argument found with clang scan-build --- lib/ykpiv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ykpiv.c b/lib/ykpiv.c index 6ced772..73ff743 100644 --- a/lib/ykpiv.c +++ b/lib/ykpiv.c @@ -664,9 +664,11 @@ ykpiv_rc ykpiv_verify(ykpiv_state *state, const char *pin, int *tries) { apdu.st.p1 = 0x00; apdu.st.p2 = 0x80; apdu.st.lc = pin ? 0x08 : 0; - memcpy(apdu.st.data, pin, len); - if(pin && len < 8) { - memset(apdu.st.data + len, 0xff, 8 - len); + if(pin) { + memcpy(apdu.st.data, pin, len); + if(len < 8) { + memset(apdu.st.data + len, 0xff, 8 - len); + } } if((res = send_data(state, &apdu, data, &recv_len, &sw)) != YKPIV_OK) { return res;