@@ -42,37 +42,6 @@ loff_t_to_s64(loff_t offset)
4242 return res ;
4343}
4444
45- /*
46- * XDR functions for basic NLM types
47- */
48- static __be32 *
49- nlm4_decode_cookie (__be32 * p , struct nlm_cookie * c )
50- {
51- unsigned int len ;
52-
53- len = ntohl (* p ++ );
54-
55- if (len == 0 )
56- {
57- c -> len = 4 ;
58- memset (c -> data , 0 , 4 ); /* hockeypux brain damage */
59- }
60- else if (len <=NLM_MAXCOOKIELEN )
61- {
62- c -> len = len ;
63- memcpy (c -> data , p , len );
64- p += XDR_QUADLEN (len );
65- }
66- else
67- {
68- dprintk ("lockd: bad cookie size %d (only cookies under "
69- "%d bytes are supported.)\n" ,
70- len , NLM_MAXCOOKIELEN );
71- return NULL ;
72- }
73- return p ;
74- }
75-
7645static __be32 *
7746nlm4_encode_cookie (__be32 * p , struct nlm_cookie * c )
7847{
@@ -82,20 +51,6 @@ nlm4_encode_cookie(__be32 *p, struct nlm_cookie *c)
8251 return p ;
8352}
8453
85- static __be32 *
86- nlm4_decode_fh (__be32 * p , struct nfs_fh * f )
87- {
88- memset (f -> data , 0 , sizeof (f -> data ));
89- f -> size = ntohl (* p ++ );
90- if (f -> size > NFS_MAXFHSIZE ) {
91- dprintk ("lockd: bad fhandle size %d (should be <=%d)\n" ,
92- f -> size , NFS_MAXFHSIZE );
93- return NULL ;
94- }
95- memcpy (f -> data , p , f -> size );
96- return p + XDR_QUADLEN (f -> size );
97- }
98-
9954/*
10055 * NLM file handles are defined by specification to be a variable-length
10156 * XDR opaque no longer than 1024 bytes. However, this implementation
@@ -122,15 +77,6 @@ svcxdr_decode_fhandle(struct xdr_stream *xdr, struct nfs_fh *fh)
12277 return true;
12378}
12479
125- /*
126- * Encode and decode owner handle
127- */
128- static __be32 *
129- nlm4_decode_oh (__be32 * p , struct xdr_netobj * oh )
130- {
131- return xdr_decode_netobj (p , oh );
132- }
133-
13480static bool
13581svcxdr_decode_lock (struct xdr_stream * xdr , struct nlm_lock * lock )
13682{
@@ -335,35 +281,42 @@ nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p)
335281 return 1 ;
336282}
337283
338- int
339- nlm4svc_encode_testres (struct svc_rqst * rqstp , __be32 * p )
340- {
341- struct nlm_res * resp = rqstp -> rq_resp ;
342-
343- if (!(p = nlm4_encode_testres (p , resp )))
344- return 0 ;
345- return xdr_ressize_check (rqstp , p );
346- }
347-
348284int
349285nlm4svc_decode_shareargs (struct svc_rqst * rqstp , __be32 * p )
350286{
287+ struct xdr_stream * xdr = & rqstp -> rq_arg_stream ;
351288 struct nlm_args * argp = rqstp -> rq_argp ;
352289 struct nlm_lock * lock = & argp -> lock ;
353290
354291 memset (lock , 0 , sizeof (* lock ));
355292 locks_init_lock (& lock -> fl );
356- lock -> svid = ~(u32 ) 0 ;
293+ lock -> svid = ~(u32 )0 ;
357294
358- if (!(p = nlm4_decode_cookie (p , & argp -> cookie ))
359- || !(p = xdr_decode_string_inplace (p , & lock -> caller ,
360- & lock -> len , NLM_MAXSTRLEN ))
361- || !(p = nlm4_decode_fh (p , & lock -> fh ))
362- || !(p = nlm4_decode_oh (p , & lock -> oh )))
295+ if (!svcxdr_decode_cookie (xdr , & argp -> cookie ))
363296 return 0 ;
364- argp -> fsm_mode = ntohl (* p ++ );
365- argp -> fsm_access = ntohl (* p ++ );
366- return xdr_argsize_check (rqstp , p );
297+ if (!svcxdr_decode_string (xdr , & lock -> caller , & lock -> len ))
298+ return 0 ;
299+ if (!svcxdr_decode_fhandle (xdr , & lock -> fh ))
300+ return 0 ;
301+ if (!svcxdr_decode_owner (xdr , & lock -> oh ))
302+ return 0 ;
303+ /* XXX: Range checks are missing in the original code */
304+ if (xdr_stream_decode_u32 (xdr , & argp -> fsm_mode ) < 0 )
305+ return 0 ;
306+ if (xdr_stream_decode_u32 (xdr , & argp -> fsm_access ) < 0 )
307+ return 0 ;
308+
309+ return 1 ;
310+ }
311+
312+ int
313+ nlm4svc_encode_testres (struct svc_rqst * rqstp , __be32 * p )
314+ {
315+ struct nlm_res * resp = rqstp -> rq_resp ;
316+
317+ if (!(p = nlm4_encode_testres (p , resp )))
318+ return 0 ;
319+ return xdr_ressize_check (rqstp , p );
367320}
368321
369322int
0 commit comments