callback: handles xdr decode errors

instead of ignoring errors from proc_cb_compound_args(), return NFS4ERR_BADXDR.  note that we still need to allocate the cb_compound_res structure to return this error

added null checks to the end of handle_cb_compound(); if the cb_compound_res allocation fails, we'd crash trying to access res->status and res->resarray_count

also fixed some indenting

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2011-01-10 13:58:55 -05:00
parent 034b2b4ea2
commit 238a8a7015

View file

@ -238,15 +238,12 @@ static void handle_cb_compound(nfs41_rpc_clnt *rpc_clnt, cb_req *req, struct cb_
XDR *xdr = (XDR*)req->xdr;
uint32_t i, status = NFS4_OK;
dprintf(CBSLVL, "--> handle_compound()\n");
dprintf(CBSLVL, "--> handle_cb_compound()\n");
/* decode the arguments */
proc_cb_compound_args(xdr, &args);
dprintf(CBSLVL, "CB_COMPOUND('%s', %u)\n", args.tag.str, args.argarray_count);
if (args.minorversion != 1) {
status = NFS4ERR_MINOR_VERS_MISMATCH; //XXXXX
eprintf("args.minorversion %u != 1\n", args.minorversion);
goto out;
if (!proc_cb_compound_args(xdr, &args)) {
status = NFS4ERR_BADXDR;
eprintf("failed to decode compound arguments\n");
}
/* allocate the compound results */
@ -255,7 +252,7 @@ static void handle_cb_compound(nfs41_rpc_clnt *rpc_clnt, cb_req *req, struct cb_
status = NFS4ERR_RESOURCE;
goto out;
}
res->status = NFS4_OK;
res->status = status;
StringCchCopyA(res->tag.str, CB_COMPOUND_MAX_TAG, g_server_tag);
res->tag.str[CB_COMPOUND_MAX_TAG-1] = 0;
res->tag.len = (uint32_t)strlen(res->tag.str);
@ -265,6 +262,13 @@ static void handle_cb_compound(nfs41_rpc_clnt *rpc_clnt, cb_req *req, struct cb_
goto out;
}
dprintf(CBSLVL, "CB_COMPOUND('%s', %u)\n", args.tag.str, args.argarray_count);
if (args.minorversion != 1) {
res->status = NFS4ERR_MINOR_VERS_MISMATCH; //XXXXX
eprintf("args.minorversion %u != 1\n", args.minorversion);
goto out;
}
/* handle each operation in the compound */
for (i = 0; i < args.argarray_count && res->status == NFS4_OK; i++) {
argop = &args.argarray[i];
@ -363,8 +367,9 @@ out:
proc_cb_compound_args(xdr, &args);
*reply = res;
dprintf(CBSLVL, "<-- handle_compound() returning %s (%u results)\n",
nfs_error_string(res->status), res->resarray_count);
dprintf(CBSLVL, "<-- handle_cb_compound() returning %s (%u results)\n",
nfs_error_string(res ? res->status : status),
res ? res->resarray_count : 0);
}
int nfs41_handle_callback(void *rpc_clnt, void *cb, struct cb_compound_res **reply)