From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-x230.google.com (mail-yw0-x230.google.com [IPv6:2607:f8b0:4002:c05::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B62A21A1E3A for ; Mon, 24 Oct 2016 00:57:54 -0700 (PDT) Received: by mail-yw0-x230.google.com with SMTP id t193so175784902ywc.2 for ; Mon, 24 Oct 2016 00:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VPpVsm9qHkYvfl9vqaHDoC2gVWtW0bz8EOHhVxx6B9Q=; b=Cphuu7/KUqF0wSHWO4mrH5EPvEHnmWzH0ZG5/odLbzfziMrtELSJRphbAWZJrkxfRb Ajhxac242u01Ic2Q5CJKw2yBY9Q5L8NPYFilwwrVAdTFjrFHwyHNW9p23OjvfSj+y2hR 5WiRzCYijGZ92j0xSm/5Xo5MLzUR9KiVg9/BQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VPpVsm9qHkYvfl9vqaHDoC2gVWtW0bz8EOHhVxx6B9Q=; b=cFFfkZSAe9VnCYmVZgzkwWfoHV6TC+J4fcRls9b/3wjyyGOnkvXqz1SBhGQdFvNTY3 N+v9bZpQrCFW7t6oE6F+WiFadDdeznrDaaQs4aX8spz23db7vBSpfWqylvLYm8uFUCc0 rkd6+qpBIsHy/rmDQoP1fqSKfytLhBh/bugQF+WSxdo/XJFtqyCJbNEf4xpVvbjMkZza vr8eEMvQZh0i6pdt09CQcFo316yyT/Vk3wA3KdIWSYXY06D4MVefDI7UwbtwOU6K0NPp cQUhtQmBJRIqDYZUDlH7NdDIcpKSi/N2MEwuiWWvb/B1DzSxUAfw06bxKWkdMhxO0L0A EDGQ== X-Gm-Message-State: ABUngvfadgfUpa0VJ1MeRT1Ph0ZDMav54mf1EBmHKEbgbWIe7E3rikc83vYOfN+Aepv2LRS+ZrLLHGX89J/THmCF X-Received: by 10.107.2.65 with SMTP id 62mr11071999ioc.83.1477295873612; Mon, 24 Oct 2016 00:57:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.5.139 with HTTP; Mon, 24 Oct 2016 00:57:53 -0700 (PDT) In-Reply-To: <20161021212737.15974-19-lersek@redhat.com> References: <20161021212737.15974-1-lersek@redhat.com> <20161021212737.15974-19-lersek@redhat.com> From: Ard Biesheuvel Date: Mon, 24 Oct 2016 08:57:53 +0100 Message-ID: To: Laszlo Ersek Cc: edk2-devel-01 , Leif Lindholm , Michael Zimmermann Subject: Re: [PATCH 18/19] ArmPkg/DefaultExceptionHandlerLib: replace AsciiStrCat() with AsciiStrCatS() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2016 07:57:55 -0000 Content-Type: text/plain; charset=UTF-8 On 21 October 2016 at 22:27, Laszlo Ersek wrote: > AsciiStrCat() is deprecated / disabled under the > DISABLE_NEW_DEPRECATED_INTERFACES feature test macro. > > The caller of CpsrString() is required to pass in "ReturnStr" with 32 > CHAR8 elements. (DefaultExceptionHandler() complies with this.) "Str" is > used to build "ReturnStr" gradually. Just before calling AsciiStrCat(), > "Str" points to the then-terminating NUL character in "ReturnStr". > > The difference (Str - ReturnStr) gives the number of non-NUL characters > we've written thus far, hence (32 - (Str - ReturnStr)) yields the number > of remaining bytes in ReturnStr, including the ultimately terminating NUL > character. > > Cc: Ard Biesheuvel > Cc: Leif Lindholm > Cc: Michael Zimmermann > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=164 > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=165 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Laszlo Ersek > --- > > Notes: > - build-tested only > > - Michael (CC'd) had posted a patch earlier for this: > , > but I only noticed that now that he pointed it out, in > . > I'll leave it to the ArmPkg maintainers to choose one; I don't feel > strongly either way. > > ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c > index aece26355e2e..4b2ee9a9acf7 100644 > --- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c > +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c > @@ -116,7 +116,10 @@ CpsrString ( > break; > } > > - AsciiStrCat (Str, ModeStr); > + // > + // See the interface contract in the leading comment block. > + // > + AsciiStrCatS (Str, 32 - (Str - ReturnStr), ModeStr); > return; Could you please use a symbolic constant for this '32', and replace it in the declaration of CpsrStr[] as well? With that Reviewed-by: Ard Biesheuvel Oh, and if the bogus 'return' happens to get lost along the way as well, I would not mind.