- if (xdr_int(&xdr, &recordmarker) == 0) {
- rpc_set_error(rpc, "xdr_int reading recordmarker failed");
- xdr_destroy(&xdr);
+ if (zdr_int(&zdr, &recordmarker) == 0) {
+ rpc_set_error(rpc, "zdr_int reading recordmarker failed");
+ zdr_destroy(&zdr);
+ return -1;
+ }
+ if (!(recordmarker&0x80000000)) {
+ zdr_destroy(&zdr);
+ if (rpc_add_fragment(rpc, buf+4, size-4) != 0) {
+ rpc_set_error(rpc, "Failed to queue fragment for reassembly.");
+ return -1;
+ }
+ return 0;
+ }
+ }
+
+ /* reassembly */
+ if (recordmarker != 0 && rpc->fragments != NULL) {
+ struct rpc_fragment *fragment;
+ uint32_t total = size - 4;
+ char *ptr;
+
+ zdr_destroy(&zdr);
+ 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);