xdr.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /*
  2. * linux/fs/lockd/xdr.c
  3. *
  4. * XDR support for lockd and the lock client.
  5. *
  6. * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  7. */
  8. #include <linux/types.h>
  9. #include <linux/sched.h>
  10. #include <linux/utsname.h>
  11. #include <linux/nfs.h>
  12. #include <linux/sunrpc/xdr.h>
  13. #include <linux/sunrpc/clnt.h>
  14. #include <linux/sunrpc/svc.h>
  15. #include <linux/sunrpc/stats.h>
  16. #include <linux/lockd/lockd.h>
  17. #define NLMDBG_FACILITY NLMDBG_XDR
  18. static inline loff_t
  19. s32_to_loff_t(__s32 offset)
  20. {
  21. return (loff_t)offset;
  22. }
  23. static inline __s32
  24. loff_t_to_s32(loff_t offset)
  25. {
  26. __s32 res;
  27. if (offset >= NLM_OFFSET_MAX)
  28. res = NLM_OFFSET_MAX;
  29. else if (offset <= -NLM_OFFSET_MAX)
  30. res = -NLM_OFFSET_MAX;
  31. else
  32. res = offset;
  33. return res;
  34. }
  35. /*
  36. * XDR functions for basic NLM types
  37. */
  38. static __be32 *nlm_decode_cookie(__be32 *p, struct nlm_cookie *c)
  39. {
  40. unsigned int len;
  41. len = ntohl(*p++);
  42. if(len==0)
  43. {
  44. c->len=4;
  45. memset(c->data, 0, 4); /* hockeypux brain damage */
  46. }
  47. else if(len<=NLM_MAXCOOKIELEN)
  48. {
  49. c->len=len;
  50. memcpy(c->data, p, len);
  51. p+=XDR_QUADLEN(len);
  52. }
  53. else
  54. {
  55. dprintk("lockd: bad cookie size %d (only cookies under "
  56. "%d bytes are supported.)\n",
  57. len, NLM_MAXCOOKIELEN);
  58. return NULL;
  59. }
  60. return p;
  61. }
  62. static inline __be32 *
  63. nlm_encode_cookie(__be32 *p, struct nlm_cookie *c)
  64. {
  65. *p++ = htonl(c->len);
  66. memcpy(p, c->data, c->len);
  67. p+=XDR_QUADLEN(c->len);
  68. return p;
  69. }
  70. static __be32 *
  71. nlm_decode_fh(__be32 *p, struct nfs_fh *f)
  72. {
  73. unsigned int len;
  74. if ((len = ntohl(*p++)) != NFS2_FHSIZE) {
  75. dprintk("lockd: bad fhandle size %d (should be %d)\n",
  76. len, NFS2_FHSIZE);
  77. return NULL;
  78. }
  79. f->size = NFS2_FHSIZE;
  80. memset(f->data, 0, sizeof(f->data));
  81. memcpy(f->data, p, NFS2_FHSIZE);
  82. return p + XDR_QUADLEN(NFS2_FHSIZE);
  83. }
  84. static inline __be32 *
  85. nlm_encode_fh(__be32 *p, struct nfs_fh *f)
  86. {
  87. *p++ = htonl(NFS2_FHSIZE);
  88. memcpy(p, f->data, NFS2_FHSIZE);
  89. return p + XDR_QUADLEN(NFS2_FHSIZE);
  90. }
  91. /*
  92. * Encode and decode owner handle
  93. */
  94. static inline __be32 *
  95. nlm_decode_oh(__be32 *p, struct xdr_netobj *oh)
  96. {
  97. return xdr_decode_netobj(p, oh);
  98. }
  99. static inline __be32 *
  100. nlm_encode_oh(__be32 *p, struct xdr_netobj *oh)
  101. {
  102. return xdr_encode_netobj(p, oh);
  103. }
  104. static __be32 *
  105. nlm_decode_lock(__be32 *p, struct nlm_lock *lock)
  106. {
  107. struct file_lock *fl = &lock->fl;
  108. s32 start, len, end;
  109. if (!(p = xdr_decode_string_inplace(p, &lock->caller,
  110. &lock->len,
  111. NLM_MAXSTRLEN))
  112. || !(p = nlm_decode_fh(p, &lock->fh))
  113. || !(p = nlm_decode_oh(p, &lock->oh)))
  114. return NULL;
  115. lock->svid = ntohl(*p++);
  116. locks_init_lock(fl);
  117. fl->fl_owner = current->files;
  118. fl->fl_pid = (pid_t)lock->svid;
  119. fl->fl_flags = FL_POSIX;
  120. fl->fl_type = F_RDLCK; /* as good as anything else */
  121. start = ntohl(*p++);
  122. len = ntohl(*p++);
  123. end = start + len - 1;
  124. fl->fl_start = s32_to_loff_t(start);
  125. if (len == 0 || end < 0)
  126. fl->fl_end = OFFSET_MAX;
  127. else
  128. fl->fl_end = s32_to_loff_t(end);
  129. return p;
  130. }
  131. /*
  132. * Encode a lock as part of an NLM call
  133. */
  134. static __be32 *
  135. nlm_encode_lock(__be32 *p, struct nlm_lock *lock)
  136. {
  137. struct file_lock *fl = &lock->fl;
  138. __s32 start, len;
  139. if (!(p = xdr_encode_string(p, lock->caller))
  140. || !(p = nlm_encode_fh(p, &lock->fh))
  141. || !(p = nlm_encode_oh(p, &lock->oh)))
  142. return NULL;
  143. if (fl->fl_start > NLM_OFFSET_MAX
  144. || (fl->fl_end > NLM_OFFSET_MAX && fl->fl_end != OFFSET_MAX))
  145. return NULL;
  146. start = loff_t_to_s32(fl->fl_start);
  147. if (fl->fl_end == OFFSET_MAX)
  148. len = 0;
  149. else
  150. len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
  151. *p++ = htonl(lock->svid);
  152. *p++ = htonl(start);
  153. *p++ = htonl(len);
  154. return p;
  155. }
  156. /*
  157. * Encode result of a TEST/TEST_MSG call
  158. */
  159. static __be32 *
  160. nlm_encode_testres(__be32 *p, struct nlm_res *resp)
  161. {
  162. s32 start, len;
  163. if (!(p = nlm_encode_cookie(p, &resp->cookie)))
  164. return NULL;
  165. *p++ = resp->status;
  166. if (resp->status == nlm_lck_denied) {
  167. struct file_lock *fl = &resp->lock.fl;
  168. *p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one;
  169. *p++ = htonl(resp->lock.svid);
  170. /* Encode owner handle. */
  171. if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
  172. return NULL;
  173. start = loff_t_to_s32(fl->fl_start);
  174. if (fl->fl_end == OFFSET_MAX)
  175. len = 0;
  176. else
  177. len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
  178. *p++ = htonl(start);
  179. *p++ = htonl(len);
  180. }
  181. return p;
  182. }
  183. /*
  184. * First, the server side XDR functions
  185. */
  186. int
  187. nlmsvc_decode_testargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
  188. {
  189. u32 exclusive;
  190. if (!(p = nlm_decode_cookie(p, &argp->cookie)))
  191. return 0;
  192. exclusive = ntohl(*p++);
  193. if (!(p = nlm_decode_lock(p, &argp->lock)))
  194. return 0;
  195. if (exclusive)
  196. argp->lock.fl.fl_type = F_WRLCK;
  197. return xdr_argsize_check(rqstp, p);
  198. }
  199. int
  200. nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
  201. {
  202. if (!(p = nlm_encode_testres(p, resp)))
  203. return 0;
  204. return xdr_ressize_check(rqstp, p);
  205. }
  206. int
  207. nlmsvc_decode_lockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
  208. {
  209. u32 exclusive;
  210. if (!(p = nlm_decode_cookie(p, &argp->cookie)))
  211. return 0;
  212. argp->block = ntohl(*p++);
  213. exclusive = ntohl(*p++);
  214. if (!(p = nlm_decode_lock(p, &argp->lock)))
  215. return 0;
  216. if (exclusive)
  217. argp->lock.fl.fl_type = F_WRLCK;
  218. argp->reclaim = ntohl(*p++);
  219. argp->state = ntohl(*p++);
  220. argp->monitor = 1; /* monitor client by default */
  221. return xdr_argsize_check(rqstp, p);
  222. }
  223. int
  224. nlmsvc_decode_cancargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
  225. {
  226. u32 exclusive;
  227. if (!(p = nlm_decode_cookie(p, &argp->cookie)))
  228. return 0;
  229. argp->block = ntohl(*p++);
  230. exclusive = ntohl(*p++);
  231. if (!(p = nlm_decode_lock(p, &argp->lock)))
  232. return 0;
  233. if (exclusive)
  234. argp->lock.fl.fl_type = F_WRLCK;
  235. return xdr_argsize_check(rqstp, p);
  236. }
  237. int
  238. nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
  239. {
  240. if (!(p = nlm_decode_cookie(p, &argp->cookie))
  241. || !(p = nlm_decode_lock(p, &argp->lock)))
  242. return 0;
  243. argp->lock.fl.fl_type = F_UNLCK;
  244. return xdr_argsize_check(rqstp, p);
  245. }
  246. int
  247. nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p, nlm_args *argp)
  248. {
  249. struct nlm_lock *lock = &argp->lock;
  250. memset(lock, 0, sizeof(*lock));
  251. locks_init_lock(&lock->fl);
  252. lock->svid = ~(u32) 0;
  253. lock->fl.fl_pid = (pid_t)lock->svid;
  254. if (!(p = nlm_decode_cookie(p, &argp->cookie))
  255. || !(p = xdr_decode_string_inplace(p, &lock->caller,
  256. &lock->len, NLM_MAXSTRLEN))
  257. || !(p = nlm_decode_fh(p, &lock->fh))
  258. || !(p = nlm_decode_oh(p, &lock->oh)))
  259. return 0;
  260. argp->fsm_mode = ntohl(*p++);
  261. argp->fsm_access = ntohl(*p++);
  262. return xdr_argsize_check(rqstp, p);
  263. }
  264. int
  265. nlmsvc_encode_shareres(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
  266. {
  267. if (!(p = nlm_encode_cookie(p, &resp->cookie)))
  268. return 0;
  269. *p++ = resp->status;
  270. *p++ = xdr_zero; /* sequence argument */
  271. return xdr_ressize_check(rqstp, p);
  272. }
  273. int
  274. nlmsvc_encode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
  275. {
  276. if (!(p = nlm_encode_cookie(p, &resp->cookie)))
  277. return 0;
  278. *p++ = resp->status;
  279. return xdr_ressize_check(rqstp, p);
  280. }
  281. int
  282. nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)
  283. {
  284. struct nlm_lock *lock = &argp->lock;
  285. if (!(p = xdr_decode_string_inplace(p, &lock->caller,
  286. &lock->len, NLM_MAXSTRLEN)))
  287. return 0;
  288. argp->state = ntohl(*p++);
  289. return xdr_argsize_check(rqstp, p);
  290. }
  291. int
  292. nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
  293. {
  294. if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
  295. return 0;
  296. argp->state = ntohl(*p++);
  297. memcpy(&argp->priv.data, p, sizeof(argp->priv.data));
  298. p += XDR_QUADLEN(SM_PRIV_SIZE);
  299. return xdr_argsize_check(rqstp, p);
  300. }
  301. int
  302. nlmsvc_decode_res(struct svc_rqst *rqstp, __be32 *p, struct nlm_res *resp)
  303. {
  304. if (!(p = nlm_decode_cookie(p, &resp->cookie)))
  305. return 0;
  306. resp->status = *p++;
  307. return xdr_argsize_check(rqstp, p);
  308. }
  309. int
  310. nlmsvc_decode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
  311. {
  312. return xdr_argsize_check(rqstp, p);
  313. }
  314. int
  315. nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
  316. {
  317. return xdr_ressize_check(rqstp, p);
  318. }
  319. /*
  320. * Now, the client side XDR functions
  321. */
  322. #ifdef NLMCLNT_SUPPORT_SHARES
  323. static int
  324. nlmclt_decode_void(struct rpc_rqst *req, u32 *p, void *ptr)
  325. {
  326. return 0;
  327. }
  328. #endif
  329. static int
  330. nlmclt_encode_testargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
  331. {
  332. struct nlm_lock *lock = &argp->lock;
  333. if (!(p = nlm_encode_cookie(p, &argp->cookie)))
  334. return -EIO;
  335. *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero;
  336. if (!(p = nlm_encode_lock(p, lock)))
  337. return -EIO;
  338. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  339. return 0;
  340. }
  341. static int
  342. nlmclt_decode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
  343. {
  344. if (!(p = nlm_decode_cookie(p, &resp->cookie)))
  345. return -EIO;
  346. resp->status = *p++;
  347. if (resp->status == nlm_lck_denied) {
  348. struct file_lock *fl = &resp->lock.fl;
  349. u32 excl;
  350. s32 start, len, end;
  351. memset(&resp->lock, 0, sizeof(resp->lock));
  352. locks_init_lock(fl);
  353. excl = ntohl(*p++);
  354. resp->lock.svid = ntohl(*p++);
  355. fl->fl_pid = (pid_t)resp->lock.svid;
  356. if (!(p = nlm_decode_oh(p, &resp->lock.oh)))
  357. return -EIO;
  358. fl->fl_flags = FL_POSIX;
  359. fl->fl_type = excl? F_WRLCK : F_RDLCK;
  360. start = ntohl(*p++);
  361. len = ntohl(*p++);
  362. end = start + len - 1;
  363. fl->fl_start = s32_to_loff_t(start);
  364. if (len == 0 || end < 0)
  365. fl->fl_end = OFFSET_MAX;
  366. else
  367. fl->fl_end = s32_to_loff_t(end);
  368. }
  369. return 0;
  370. }
  371. static int
  372. nlmclt_encode_lockargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
  373. {
  374. struct nlm_lock *lock = &argp->lock;
  375. if (!(p = nlm_encode_cookie(p, &argp->cookie)))
  376. return -EIO;
  377. *p++ = argp->block? xdr_one : xdr_zero;
  378. *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero;
  379. if (!(p = nlm_encode_lock(p, lock)))
  380. return -EIO;
  381. *p++ = argp->reclaim? xdr_one : xdr_zero;
  382. *p++ = htonl(argp->state);
  383. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  384. return 0;
  385. }
  386. static int
  387. nlmclt_encode_cancargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
  388. {
  389. struct nlm_lock *lock = &argp->lock;
  390. if (!(p = nlm_encode_cookie(p, &argp->cookie)))
  391. return -EIO;
  392. *p++ = argp->block? xdr_one : xdr_zero;
  393. *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero;
  394. if (!(p = nlm_encode_lock(p, lock)))
  395. return -EIO;
  396. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  397. return 0;
  398. }
  399. static int
  400. nlmclt_encode_unlockargs(struct rpc_rqst *req, __be32 *p, nlm_args *argp)
  401. {
  402. struct nlm_lock *lock = &argp->lock;
  403. if (!(p = nlm_encode_cookie(p, &argp->cookie)))
  404. return -EIO;
  405. if (!(p = nlm_encode_lock(p, lock)))
  406. return -EIO;
  407. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  408. return 0;
  409. }
  410. static int
  411. nlmclt_encode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
  412. {
  413. if (!(p = nlm_encode_cookie(p, &resp->cookie)))
  414. return -EIO;
  415. *p++ = resp->status;
  416. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  417. return 0;
  418. }
  419. static int
  420. nlmclt_encode_testres(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
  421. {
  422. if (!(p = nlm_encode_testres(p, resp)))
  423. return -EIO;
  424. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  425. return 0;
  426. }
  427. static int
  428. nlmclt_decode_res(struct rpc_rqst *req, __be32 *p, struct nlm_res *resp)
  429. {
  430. if (!(p = nlm_decode_cookie(p, &resp->cookie)))
  431. return -EIO;
  432. resp->status = *p++;
  433. return 0;
  434. }
  435. #if (NLMCLNT_OHSIZE > XDR_MAX_NETOBJ)
  436. # error "NLM host name cannot be larger than XDR_MAX_NETOBJ!"
  437. #endif
  438. /*
  439. * Buffer requirements for NLM
  440. */
  441. #define NLM_void_sz 0
  442. #define NLM_cookie_sz 1+XDR_QUADLEN(NLM_MAXCOOKIELEN)
  443. #define NLM_caller_sz 1+XDR_QUADLEN(NLMCLNT_OHSIZE)
  444. #define NLM_owner_sz 1+XDR_QUADLEN(NLMCLNT_OHSIZE)
  445. #define NLM_fhandle_sz 1+XDR_QUADLEN(NFS2_FHSIZE)
  446. #define NLM_lock_sz 3+NLM_caller_sz+NLM_owner_sz+NLM_fhandle_sz
  447. #define NLM_holder_sz 4+NLM_owner_sz
  448. #define NLM_testargs_sz NLM_cookie_sz+1+NLM_lock_sz
  449. #define NLM_lockargs_sz NLM_cookie_sz+4+NLM_lock_sz
  450. #define NLM_cancargs_sz NLM_cookie_sz+2+NLM_lock_sz
  451. #define NLM_unlockargs_sz NLM_cookie_sz+NLM_lock_sz
  452. #define NLM_testres_sz NLM_cookie_sz+1+NLM_holder_sz
  453. #define NLM_res_sz NLM_cookie_sz+1
  454. #define NLM_norep_sz 0
  455. /*
  456. * For NLM, a void procedure really returns nothing
  457. */
  458. #define nlmclt_decode_norep NULL
  459. #define PROC(proc, argtype, restype) \
  460. [NLMPROC_##proc] = { \
  461. .p_proc = NLMPROC_##proc, \
  462. .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \
  463. .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \
  464. .p_arglen = NLM_##argtype##_sz, \
  465. .p_replen = NLM_##restype##_sz, \
  466. .p_statidx = NLMPROC_##proc, \
  467. .p_name = #proc, \
  468. }
  469. static struct rpc_procinfo nlm_procedures[] = {
  470. PROC(TEST, testargs, testres),
  471. PROC(LOCK, lockargs, res),
  472. PROC(CANCEL, cancargs, res),
  473. PROC(UNLOCK, unlockargs, res),
  474. PROC(GRANTED, testargs, res),
  475. PROC(TEST_MSG, testargs, norep),
  476. PROC(LOCK_MSG, lockargs, norep),
  477. PROC(CANCEL_MSG, cancargs, norep),
  478. PROC(UNLOCK_MSG, unlockargs, norep),
  479. PROC(GRANTED_MSG, testargs, norep),
  480. PROC(TEST_RES, testres, norep),
  481. PROC(LOCK_RES, res, norep),
  482. PROC(CANCEL_RES, res, norep),
  483. PROC(UNLOCK_RES, res, norep),
  484. PROC(GRANTED_RES, res, norep),
  485. #ifdef NLMCLNT_SUPPORT_SHARES
  486. PROC(SHARE, shareargs, shareres),
  487. PROC(UNSHARE, shareargs, shareres),
  488. PROC(NM_LOCK, lockargs, res),
  489. PROC(FREE_ALL, notify, void),
  490. #endif
  491. };
  492. static struct rpc_version nlm_version1 = {
  493. .number = 1,
  494. .nrprocs = 16,
  495. .procs = nlm_procedures,
  496. };
  497. static struct rpc_version nlm_version3 = {
  498. .number = 3,
  499. .nrprocs = 24,
  500. .procs = nlm_procedures,
  501. };
  502. static struct rpc_version * nlm_versions[] = {
  503. [1] = &nlm_version1,
  504. [3] = &nlm_version3,
  505. #ifdef CONFIG_LOCKD_V4
  506. [4] = &nlm_version4,
  507. #endif
  508. };
  509. static struct rpc_stat nlm_stats;
  510. struct rpc_program nlm_program = {
  511. .name = "lockd",
  512. .number = NLM_PROGRAM,
  513. .nrvers = ARRAY_SIZE(nlm_versions),
  514. .version = nlm_versions,
  515. .stats = &nlm_stats,
  516. };
  517. #ifdef RPC_DEBUG
  518. const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie)
  519. {
  520. /*
  521. * We can get away with a static buffer because we're only
  522. * called with BKL held.
  523. */
  524. static char buf[2*NLM_MAXCOOKIELEN+1];
  525. unsigned int i, len = sizeof(buf);
  526. char *p = buf;
  527. len--; /* allow for trailing \0 */
  528. if (len < 3)
  529. return "???";
  530. for (i = 0 ; i < cookie->len ; i++) {
  531. if (len < 2) {
  532. strcpy(p-3, "...");
  533. break;
  534. }
  535. sprintf(p, "%02x", cookie->data[i]);
  536. p += 2;
  537. len -= 2;
  538. }
  539. *p = '\0';
  540. return buf;
  541. }
  542. #endif