@@ -42,37 +42,6 @@ loff_t_to_s64(loff_t offset)
42
42
return res ;
43
43
}
44
44
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
-
76
45
static __be32 *
77
46
nlm4_encode_cookie (__be32 * p , struct nlm_cookie * c )
78
47
{
@@ -82,20 +51,6 @@ nlm4_encode_cookie(__be32 *p, struct nlm_cookie *c)
82
51
return p ;
83
52
}
84
53
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
-
99
54
/*
100
55
* NLM file handles are defined by specification to be a variable-length
101
56
* 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)
122
77
return true;
123
78
}
124
79
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
-
134
80
static bool
135
81
svcxdr_decode_lock (struct xdr_stream * xdr , struct nlm_lock * lock )
136
82
{
@@ -335,35 +281,42 @@ nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p)
335
281
return 1 ;
336
282
}
337
283
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
-
348
284
int
349
285
nlm4svc_decode_shareargs (struct svc_rqst * rqstp , __be32 * p )
350
286
{
287
+ struct xdr_stream * xdr = & rqstp -> rq_arg_stream ;
351
288
struct nlm_args * argp = rqstp -> rq_argp ;
352
289
struct nlm_lock * lock = & argp -> lock ;
353
290
354
291
memset (lock , 0 , sizeof (* lock ));
355
292
locks_init_lock (& lock -> fl );
356
- lock -> svid = ~(u32 ) 0 ;
293
+ lock -> svid = ~(u32 )0 ;
357
294
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 ))
363
296
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 );
367
320
}
368
321
369
322
int
0 commit comments