Blame 0114-libcacard-replace-pstrcpy-with-memcpy.patch

0410ae
From c916d06403eec41a92eabf52b31102d3b7068da8 Mon Sep 17 00:00:00 2001
0410ae
From: Michael Tokarev <mjt@tls.msk.ru>
0410ae
Date: Fri, 2 May 2014 18:35:59 +0400
0410ae
Subject: [PATCH] libcacard: replace pstrcpy() with memcpy()
0410ae
0410ae
Commit 2e679780ae86c6ca8 replaced strncpy() with pstrcpy()
0410ae
in one place in libcacard.  This is a qemu-specific function,
0410ae
while libcacard is a stand-alone library (or tries to be).
0410ae
But since we know the exact length of the string to copy,
0410ae
and know that it definitely will fit in the destination
0410ae
buffer, use memcpy() instead, and null-terminate the string
0410ae
after that.
0410ae
0410ae
An alternative is to use g_strlcpy() or strncpy(), but memcpy()
0410ae
is more than adequate in this place.
0410ae
0410ae
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
0410ae
Cc: qemu-trivial@nongnu.org
0410ae
Cc: Alon Levy <alevy@redhat.com>
0410ae
(cherry picked from commit a22f8f38942623dc473bf5ced5b4117b8bdf4821)
0410ae
---
0410ae
 libcacard/vcard_emul_nss.c | 3 ++-
0410ae
 1 file changed, 2 insertions(+), 1 deletion(-)
0410ae
0410ae
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
0410ae
index ee2dfae..e2b196d 100644
0410ae
--- a/libcacard/vcard_emul_nss.c
0410ae
+++ b/libcacard/vcard_emul_nss.c
0410ae
@@ -1162,7 +1162,8 @@ vcard_emul_options(const char *args)
0410ae
             NEXT_TOKEN(vname)
0410ae
             NEXT_TOKEN(type_params)
0410ae
             type_params_length = MIN(type_params_length, sizeof(type_str)-1);
0410ae
-            pstrcpy(type_str, type_params_length, type_params);
0410ae
+            memcpy(type_str, type_params, type_params_length);
0410ae
+            type_str[type_params_length] = '\0';
0410ae
             type = vcard_emul_type_from_string(type_str);
0410ae
 
0410ae
             NEXT_TOKEN(type_params)