RE: [PATCH] SUNRPC: Increase size of servername string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: David Laight
> Sent: 25 March 2022 06:53
> 
> From: NeilBrown
> > Sent: 25 March 2022 02:07
> >
> > On Thu, 24 Mar 2022, Haowen Bai wrote:
> > > This patch will fix the warning from smatch:
> > >
> > > net/sunrpc/clnt.c:562 rpc_create() error: snprintf() chops off
> > > the last chars of 'sun->sun_path': 108 vs 48
> > >
> > > Signed-off-by: Haowen Bai <baihaowen@xxxxxxxxx>
> > > ---
> > >  net/sunrpc/clnt.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
> > > index c83fe61..6e0209e 100644
> > > --- a/net/sunrpc/clnt.c
> > > +++ b/net/sunrpc/clnt.c
> > > @@ -526,7 +526,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
> > >  		.servername = args->servername,
> > >  		.bc_xprt = args->bc_xprt,
> > >  	};
> > > -	char servername[48];
> > > +	char servername[108];
> >
> > It would be much nicer to use UNIX_PATH_MAX
> 
> Not on-stack....

Ok I looked the constant up - it is 108.
OTOH just looking at the code makes it look like a value
that is much larger - not good on stack.
Even [sizeof sun->sun_path] would probably be better.
But I don't think the copy is needed at all.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux