From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ramon Fried Date: Sat, 15 May 2021 23:03:46 +0300 Subject: [PATCH v2 01/16] sandbox: net: Ensure host name is always a valid string In-Reply-To: <20210513193923.v2.1.I85633a7354c5b2ad5c55257607280392d069d70c@changeid> References: <20210513193923.v2.1.I85633a7354c5b2ad5c55257607280392d069d70c@changeid> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, May 14, 2021 at 4:40 AM Simon Glass wrote: > > At present if ifname is exactly IFNAMSIZ characters then it will result > in an unterminated string. Fix this by using strlcpy() instead. > > Signed-off-by: Simon Glass > Reported-by: Coverity (CID: 316358) > --- > > Changes in v2: > - Put 'Reported-by:' after the sign-off > > drivers/net/sandbox-raw.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c > index ce66ff781ff..99eb7a3bbff 100644 > --- a/drivers/net/sandbox-raw.c > +++ b/drivers/net/sandbox-raw.c > @@ -161,7 +161,7 @@ static int sb_eth_raw_of_to_plat(struct udevice *dev) > > ifname = dev_read_string(dev, "host-raw-interface"); > if (ifname) { > - strncpy(priv->host_ifname, ifname, IFNAMSIZ); > + strlcpy(priv->host_ifname, ifname, IFNAMSIZ); > printf(": Using %s from DT\n", priv->host_ifname); > } > if (dev_read_u32(dev, "host-raw-interface-idx", > -- > 2.31.1.751.gd2f1c929bd-goog > Acked-by: Ramon Fried