From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Thibault Subject: Re: [PATCH 21/28] mini-os: fix nodename generation in init_netfront Date: Wed, 18 Sep 2013 13:46:55 +0200 Message-ID: <20130918114655.GN5664@type.bordeaux.inria.fr> References: <1379475484-25993-1-git-send-email-mattjd@gmail.com> <1379475484-25993-22-git-send-email-mattjd@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <1379475484-25993-22-git-send-email-mattjd@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Matthew Daley Cc: Stefano Stabellini , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Matthew Daley, le Wed 18 Sep 2013 15:37:57 +1200, a =E9crit : > Using strlen here makes no sense. > = > Coverity-ID: 1056053 > Signed-off-by: Matthew Daley Acked-by: Samuel Thibault > --- > extras/mini-os/netfront.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > = > diff --git a/extras/mini-os/netfront.c b/extras/mini-os/netfront.c > index 4e087a5..a999985 100644 > --- a/extras/mini-os/netfront.c > +++ b/extras/mini-os/netfront.c > @@ -309,8 +309,10 @@ struct netfront_dev *init_netfront(char *_nodename, = void (*thenetif_rx)(unsigned > = > if (!_nodename) > snprintf(nodename, sizeof(nodename), "device/vif/%d", netfronten= ds); > - else > - strncpy(nodename, _nodename, strlen(nodename)); > + else { > + strncpy(nodename, _nodename, sizeof(nodename) - 1); > + nodename[sizeof(nodename) - 1] =3D 0; > + } > netfrontends++; > = > if (!thenetif_rx) > -- = > 1.7.10.4 > =