21
21
22
22
#include "svcxdr.h"
23
23
24
- #define NLMDBG_FACILITY NLMDBG_XDR
25
-
26
24
27
25
static inline loff_t
28
26
s32_to_loff_t (__s32 offset )
@@ -46,33 +44,6 @@ loff_t_to_s32(loff_t offset)
46
44
/*
47
45
* XDR functions for basic NLM types
48
46
*/
49
- static __be32 * nlm_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
-
76
47
static inline __be32 *
77
48
nlm_encode_cookie (__be32 * p , struct nlm_cookie * c )
78
49
{
@@ -82,22 +53,6 @@ nlm_encode_cookie(__be32 *p, struct nlm_cookie *c)
82
53
return p ;
83
54
}
84
55
85
- static __be32 *
86
- nlm_decode_fh (__be32 * p , struct nfs_fh * f )
87
- {
88
- unsigned int len ;
89
-
90
- if ((len = ntohl (* p ++ )) != NFS2_FHSIZE ) {
91
- dprintk ("lockd: bad fhandle size %d (should be %d)\n" ,
92
- len , NFS2_FHSIZE );
93
- return NULL ;
94
- }
95
- f -> size = NFS2_FHSIZE ;
96
- memset (f -> data , 0 , sizeof (f -> data ));
97
- memcpy (f -> data , p , NFS2_FHSIZE );
98
- return p + XDR_QUADLEN (NFS2_FHSIZE );
99
- }
100
-
101
56
/*
102
57
* NLM file handles are defined by specification to be a variable-length
103
58
* XDR opaque no longer than 1024 bytes. However, this implementation
@@ -128,12 +83,6 @@ svcxdr_decode_fhandle(struct xdr_stream *xdr, struct nfs_fh *fh)
128
83
/*
129
84
* Encode and decode owner handle
130
85
*/
131
- static inline __be32 *
132
- nlm_decode_oh (__be32 * p , struct xdr_netobj * oh )
133
- {
134
- return xdr_decode_netobj (p , oh );
135
- }
136
-
137
86
static inline __be32 *
138
87
nlm_encode_oh (__be32 * p , struct xdr_netobj * oh )
139
88
{
@@ -339,35 +288,42 @@ nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p)
339
288
return 1 ;
340
289
}
341
290
342
- int
343
- nlmsvc_encode_testres (struct svc_rqst * rqstp , __be32 * p )
344
- {
345
- struct nlm_res * resp = rqstp -> rq_resp ;
346
-
347
- if (!(p = nlm_encode_testres (p , resp )))
348
- return 0 ;
349
- return xdr_ressize_check (rqstp , p );
350
- }
351
-
352
291
int
353
292
nlmsvc_decode_shareargs (struct svc_rqst * rqstp , __be32 * p )
354
293
{
294
+ struct xdr_stream * xdr = & rqstp -> rq_arg_stream ;
355
295
struct nlm_args * argp = rqstp -> rq_argp ;
356
296
struct nlm_lock * lock = & argp -> lock ;
357
297
358
298
memset (lock , 0 , sizeof (* lock ));
359
299
locks_init_lock (& lock -> fl );
360
- lock -> svid = ~(u32 ) 0 ;
300
+ lock -> svid = ~(u32 )0 ;
361
301
362
- if (!(p = nlm_decode_cookie (p , & argp -> cookie ))
363
- || !(p = xdr_decode_string_inplace (p , & lock -> caller ,
364
- & lock -> len , NLM_MAXSTRLEN ))
365
- || !(p = nlm_decode_fh (p , & lock -> fh ))
366
- || !(p = nlm_decode_oh (p , & lock -> oh )))
302
+ if (!svcxdr_decode_cookie (xdr , & argp -> cookie ))
367
303
return 0 ;
368
- argp -> fsm_mode = ntohl (* p ++ );
369
- argp -> fsm_access = ntohl (* p ++ );
370
- return xdr_argsize_check (rqstp , p );
304
+ if (!svcxdr_decode_string (xdr , & lock -> caller , & lock -> len ))
305
+ return 0 ;
306
+ if (!svcxdr_decode_fhandle (xdr , & lock -> fh ))
307
+ return 0 ;
308
+ if (!svcxdr_decode_owner (xdr , & lock -> oh ))
309
+ return 0 ;
310
+ /* XXX: Range checks are missing in the original code */
311
+ if (xdr_stream_decode_u32 (xdr , & argp -> fsm_mode ) < 0 )
312
+ return 0 ;
313
+ if (xdr_stream_decode_u32 (xdr , & argp -> fsm_access ) < 0 )
314
+ return 0 ;
315
+
316
+ return 1 ;
317
+ }
318
+
319
+ int
320
+ nlmsvc_encode_testres (struct svc_rqst * rqstp , __be32 * p )
321
+ {
322
+ struct nlm_res * resp = rqstp -> rq_resp ;
323
+
324
+ if (!(p = nlm_encode_testres (p , resp )))
325
+ return 0 ;
326
+ return xdr_ressize_check (rqstp , p );
371
327
}
372
328
373
329
int
0 commit comments