From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 537BD5A004F for ; Thu, 27 Jun 2024 03:13:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1719450799; bh=B4mPm8hTa2hzq3WjAgM7Ptg8esyNC98tt3u1HrSlBSQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pese3HExP7tywTNsGS8UPYRU0b5QvR1O//ru6gogUG2LYhtnnyRMFNl6/kY7KGCVE iBtYl4yMfIKkE8iSQHgVs4elhWmAZFGIgY6g7q9MsfYmL+5I0fcfczTuJfdJQyidxe L7IsK8wGDxa1g0ChSCNTDH3CNXCsUdvpX9gEnKS1797crsc1FiGM8S5mplojVXPBSe ZMDDFUY4ZKfcRdDacV7X4sYDjIKMcLVTkCPPunlWD5uXeSP3LNVfc0fbk3GXyzZgEl rBkw/aA/x2Irjz8V7mejqhKRffG3jdW2dr8HbVAFgW2aCeY0l/9eWdNkibOWzFg4Sb sV2xaISjWo4WA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W8gYW3HWjz4x1Y; Thu, 27 Jun 2024 11:13:19 +1000 (AEST) Date: Thu, 27 Jun 2024 10:45:28 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 1/4] conf: Copy up to MAXDNSRCH - 1 bytes, not MAXDNSRCH Message-ID: References: <20240626234536.3306466-1-sbrivio@redhat.com> <20240626234536.3306466-2-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="M2wR+YLFCDo0XdCK" Content-Disposition: inline In-Reply-To: <20240626234536.3306466-2-sbrivio@redhat.com> Message-ID-Hash: LZXWE7KNHVV3LKCZAY3PU3OP3X43DPGM X-Message-ID-Hash: LZXWE7KNHVV3LKCZAY3PU3OP3X43DPGM X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Matej Hrica X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --M2wR+YLFCDo0XdCK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 27, 2024 at 01:45:33AM +0200, Stefano Brivio wrote: > Spotted by Coverity just recently. Not that it really matters as > MAXDNSRCH always appears to be defined as 1025, while a full domain > name can have up to 253 characters: it would be a bit pointless to > have a longer search domain. >=20 > Signed-off-by: Stefano Brivio Hm. So, IIRC strncpy() won't \0 terminate in the case where it truncates. I guess we'll get away with that here since we expect c->dns_search to be filled with \0 before hand. That's... more fragile than ideal, though. > --- > conf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/conf.c b/conf.c > index e1f5422..9e47e9a 100644 > --- a/conf.c > +++ b/conf.c > @@ -453,7 +453,7 @@ static void get_dns(struct ctx *c) > while (s - c->dns_search < ARRAY_SIZE(c->dns_search) - 1 > /* cppcheck-suppress strtokCalled */ > && (p =3D strtok(NULL, " \t"))) { > - strncpy(s->n, p, sizeof(c->dns_search[0])); > + strncpy(s->n, p, sizeof(c->dns_search[0]) - 1); > s++; > *s->n =3D 0; > } --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --M2wR+YLFCDo0XdCK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZ8thgACgkQzQJF27ox 2Gc0qQ/8CMkFy2MpDJapPmnsPngXQvbuzZYRXN901Hy2d+S8+cfjk1OKMSDnIFiz 5x1WxaSx1opVKRM471d60JbuYLOnDdffi4KkwZH4X0K/WITUlUP79WT52d1iLJRP U91lvHHnJ8RysUSYj+ZOBJrIR4TtzexLZ/jsNYGGlHTFUhT+CSGNW69vZ2pGbkoI e+HRRbcMPux/vzv5Rr6Bo2JfLzTHOq19md1XIo39TNBNk3NJ60DtZkFAgvkn3ZEI kSlvNu0AioDuGDJk4Fn7OiJPwE3cFi8Mrqw9nrKqKWZGFETcaTkx8kZInhHsnEDf rCYjwuu++tDvVQe48CKnzUNtddNJjYeeKUe6+5ftUhMyz/PrunUUEIgxeiGf07DX PFiy698Sv8ZpJz1G7D9B1fF3PB3wpErOiTjUaZ/N2+/vtCYwgRuEjPUR2AH3Z+qf RA/PwIH6hN9nb/AtrJZyDJW2zpeZKWh5+VDhYoITf9mUiV1VCKmKXlTkMrOKmi4B EVoeFbDv8syj0OeOwFfa1lq8EipqGxd5wi5btOqyj2O+8TLB4PuOlWmsttWqc2mH kd7P4ScYw7wPpekLcxP4PowZ0pFCSud5YA+3NS6t++FHnRh0g6jNdshQTQQiUOSo /azEKrPsYomKtZDL4gRCL4uTXAGym1Mw8PSOzOE/WLJ0i9DZGl8= =HB6W -----END PGP SIGNATURE----- --M2wR+YLFCDo0XdCK--