From patchwork Fri May 2 14:35:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 345002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8FB27140124 for ; Sat, 3 May 2014 00:45:34 +1000 (EST) Received: from localhost ([::1]:44890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgEiS-0000E7-BX for incoming@patchwork.ozlabs.org; Fri, 02 May 2014 10:45:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgEi3-0008Bx-L5 for qemu-devel@nongnu.org; Fri, 02 May 2014 10:45:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WgEhz-0002t0-0k for qemu-devel@nongnu.org; Fri, 02 May 2014 10:45:07 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:56576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WgEhy-0002sH-Pn; Fri, 02 May 2014 10:45:02 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 29976401F9; Fri, 2 May 2014 18:45:01 +0400 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id 55374651; Fri, 2 May 2014 18:36:03 +0400 (MSK) Received: (nullmailer pid 30562 invoked by uid 1000); Fri, 02 May 2014 14:36:02 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Fri, 2 May 2014 18:35:59 +0400 Message-Id: <1399041361-30496-6-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399041361-30496-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1399041361-30496-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Michael Tokarev Subject: [Qemu-devel] [PATCH v2 5/7] libcacard: replace pstrcpy() with memcpy() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Commit 2e679780ae86c6ca8 replaced strncpy() with pstrcpy() in one place in libcacard. This is a qemu-specific function, while libcacard is a stand-alone library (or tries to be). But since we know the exact length of the string to copy, and know that it definitely will fit in the destination buffer, use memcpy() instead, and null-terminate the string after that. An alternative is to use g_strlcpy() or strncpy(), but memcpy() is more than adequate in this place. Signed-off-by: Michael Tokarev Cc: qemu-trivial@nongnu.org --- libcacard/vcard_emul_nss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index ee2dfae..e2b196d 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -1162,7 +1162,8 @@ vcard_emul_options(const char *args) NEXT_TOKEN(vname) NEXT_TOKEN(type_params) type_params_length = MIN(type_params_length, sizeof(type_str)-1); - pstrcpy(type_str, type_params_length, type_params); + memcpy(type_str, type_params, type_params_length); + type_str[type_params_length] = '\0'; type = vcard_emul_type_from_string(type_str); NEXT_TOKEN(type_params)