Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jun 2023 15:42:34 +0100
From:      Jessica Clarke <jrtc27@freebsd.org>
To:        "Simon J. Gerraty" <sjg@FreeBSD.org>
Cc:        "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>
Subject:   Re: git: 56f3f2d2491e - main - libsecureboot: avoid set but not used errors
Message-ID:  <667C347E-B7C7-405B-AFEC-F0A0FD0656F6@freebsd.org>
In-Reply-To: <202306300652.35U6qpgP027126@gitrepo.freebsd.org>
References:  <202306300652.35U6qpgP027126@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 30 Jun 2023, at 07:52, Simon J. Gerraty <sjg@FreeBSD.org> wrote:
>=20
> The branch main has been updated by sjg:
>=20
> URL: =
https://cgit.FreeBSD.org/src/commit/?id=3D56f3f2d2491e30f369f9461c3cb2a366=
bdffbe1d
>=20
> commit 56f3f2d2491e30f369f9461c3cb2a366bdffbe1d
> Author:     Simon J. Gerraty <sjg@FreeBSD.org>
> AuthorDate: 2023-06-30 06:52:17 +0000
> Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
> CommitDate: 2023-06-30 06:52:17 +0000
>=20
>    libsecureboot: avoid set but not used errors
>=20
>    Reviewed by:    stevek
> ---
> lib/libsecureboot/openpgp/opgp_sig.c | 22 ++++++++++++----------
> lib/libsecureboot/vets.c             |  7 +++++--
> 2 files changed, 17 insertions(+), 12 deletions(-)
>=20
> diff --git a/lib/libsecureboot/openpgp/opgp_sig.c =
b/lib/libsecureboot/openpgp/opgp_sig.c
> index eec3469e3457..7f4e6fb98fd1 100644
> --- a/lib/libsecureboot/openpgp/opgp_sig.c
> +++ b/lib/libsecureboot/openpgp/opgp_sig.c
> @@ -464,20 +464,22 @@ verify_asc(const char *sigfile, int flags)
> size_t n;
> unsigned char *fdata, *sdata;
> size_t fbytes, sbytes;
> -   =20
> +
> + fdata =3D NULL;
> if ((sdata =3D read_file(sigfile, &sbytes))) {
> n =3D strlcpy(pbuf, sigfile, sizeof(pbuf));
> - if ((cp =3D strrchr(pbuf, '.')))
> - *cp =3D '\0';
> - if ((fdata =3D read_file(pbuf, &fbytes))) {
> - if (openpgp_verify(pbuf, fdata, fbytes, sdata,
> - sbytes, flags)) {
> - free(fdata);
> - fdata =3D NULL;
> + if (n < sizeof(pbuf)) {
> + if ((cp =3D strrchr(pbuf, '.')))
> + *cp =3D '\0';
> + if ((fdata =3D read_file(pbuf, &fbytes))) {
> + if (openpgp_verify(pbuf, fdata, fbytes, sdata,
> + sbytes, flags)) {
> + free(fdata);
> + fdata =3D NULL;
> + }
> }
> }
> - } else
> - fdata =3D NULL;
> + }
> free(sdata);
> return (fdata);
> }
> diff --git a/lib/libsecureboot/vets.c b/lib/libsecureboot/vets.c
> index 4375dfa76a89..12191097ff8c 100644
> --- a/lib/libsecureboot/vets.c
> +++ b/lib/libsecureboot/vets.c
> @@ -241,11 +241,14 @@ x509_cn_get(br_x509_certificate *xc, char *buf, =
size_t len)
> mc.vtable->start_cert(&mc.vtable, xc->data_len);
> mc.vtable->append(&mc.vtable, xc->data, xc->data_len);
> mc.vtable->end_cert(&mc.vtable);
> - /* we don' actually care about cert status - just its name */
> + /* we don't actually care about cert status - just its name */
> err =3D mc.vtable->end_chain(&mc.vtable);
>=20
> - if (!cn.status)
> + if (!cn.status) {
> buf =3D NULL;
> + if (err =3D=3D 0) /* keep compiler happy */
> + buf =3D NULL;

This is nonsense code.

Jess

> + }
> return (buf);
> }
>=20




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?667C347E-B7C7-405B-AFEC-F0A0FD0656F6>