+
+ /* reassembly */
+ if (recordmarker != 0 && rpc->fragments != NULL) {
+ struct rpc_fragment *fragment;
+ uint64_t total = size - 4;
+ char *ptr;
+
+ xdr_destroy(&xdr);
+ for (fragment = rpc->fragments; fragment; fragment = fragment->next) {
+ total += fragment->size;
+ }
+
+ reasbuf = malloc(total);
+ if (reasbuf == NULL) {
+ rpc_set_error(rpc, "Failed to reassemble PDU");
+ rpc_free_all_fragments(rpc);
+ return -1;
+ }
+ ptr = reasbuf;
+ for (fragment = rpc->fragments; fragment; fragment = fragment->next) {
+ memcpy(ptr, fragment->data, fragment->size);
+ ptr += fragment->size;
+ }
+ memcpy(ptr, buf + 4, size - 4);
+ xdrmem_create(&xdr, reasbuf, total, XDR_DECODE);
+ rpc_free_all_fragments(rpc);
+ }
+