From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web08.9718.1642416775441302908 for ; Mon, 17 Jan 2022 02:52:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aG114a6Z; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642416774; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pH9N7Op/hXuyVCtSfIDkP0LOxNUJcMIMwecuqlhVxCY=; b=aG114a6Zcf9I+7bENwDdGsaxjORMNsLTD0gufA6ODEQeWvspSOqyiE8QZ8BtCf481Kurxp vrdMEKd56pqJEk1KgGduWJKIA9pswKPTnZ1mp5oerG/2hLkLEH/KVmxg5DwTyuYaxb+YQA sJIDUT2Uv6xg/upmSGHaDtcIJJDlo+Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-nXl_xpkpMVCVFbHY1TtEhw-1; Mon, 17 Jan 2022 05:52:51 -0500 X-MC-Unique: nXl_xpkpMVCVFbHY1TtEhw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 144A11937FC0; Mon, 17 Jan 2022 10:52:50 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE62E7AB4B; Mon, 17 Jan 2022 10:52:45 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 629B8180063D; Mon, 17 Jan 2022 11:52:34 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Xiaoyu Lu , Pawel Polawski , Guomin Jiang , Jiewen Yao , Jian J Wang , Gerd Hoffmann Subject: [PATCH 7/8] CryptoPkg/CrtLibSupport: fix strcpy Date: Mon, 17 Jan 2022 11:52:33 +0100 Message-Id: <20220117105234.1981719-8-kraxel@redhat.com> In-Reply-To: <20220117105234.1981719-1-kraxel@redhat.com> References: <20220117105234.1981719-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" strcpy() returns a pointer to the destination string, AsciiStrCpyS() does not. So a simple #define does not work. Create a inline function instead. Signed-off-by: Gerd Hoffmann --- CryptoPkg/Library/Include/CrtLibSupport.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h index fd8e8e1a938b..981ed3097b24 100644 --- a/CryptoPkg/Library/Include/CrtLibSupport.h +++ b/CryptoPkg/Library/Include/CrtLibSupport.h @@ -395,6 +395,16 @@ inet_pton ( void * ); +static inline char * +strcpy ( + char *restrict strDest, + const char *strSource + ) +{ + AsciiStrCpyS (strDest, MAX_STRING_SIZE, strSource); + return strDest; +} + // // Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions // @@ -404,7 +414,6 @@ inet_pton ( #define memcmp(buf1, buf2, count) (int)(CompareMem(buf1,buf2,(UINTN)(count))) #define memmove(dest, source, count) CopyMem(dest,source,(UINTN)(count)) #define strlen(str) (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE)) -#define strcpy(strDest, strSource) AsciiStrCpyS(strDest,MAX_STRING_SIZE,strSource) #define strncpy(strDest, strSource, count) AsciiStrnCpyS(strDest,MAX_STRING_SIZE,strSource,(UINTN)count) #define strcat(strDest, strSource) AsciiStrCatS(strDest,MAX_STRING_SIZE,strSource) #define strncmp(string1, string2, count) (int)(AsciiStrnCmp(string1,string2,(UINTN)(count))) -- 2.34.1