[ofa-general] Re: [PATCH] ipath: strncpy does not null terminate string

Roland Dreier rdreier at cisco.com
Wed Aug 5 13:39:58 PDT 2009


 > --- a/drivers/infiniband/hw/ipath/ipath_mad.c
 > +++ b/drivers/infiniband/hw/ipath/ipath_mad.c
 > @@ -60,7 +60,7 @@ static int recv_subn_get_nodedescription(struct ib_smp *smp,
 >  	if (smp->attr_mod)
 >  		smp->status |= IB_SMP_INVALID_FIELD;
 >  
 > -	strncpy(smp->data, ibdev->node_desc, sizeof(smp->data));
 > +	strlcpy(smp->data, ibdev->node_desc, sizeof(smp->data));
 >  
 >  	return reply(smp);
 >  }

node_desc isn't really a string, isn't it?  Seems that we should be
using memcpy() here (since I think it is perfectly valid according to
the IB architecture to have NULs in the node description)

 - R.



More information about the general mailing list