From bb562a12a315384e50538329bafb777cb9621a13 Mon Sep 17 00:00:00 2001 From: johann <johann> Date: Wed, 19 Sep 2007 18:57:13 +0000 Subject: [PATCH] Branch b1_6 b=13358 i=nikita i=bobijam Don't LASSERT correctness of data obtained through the network. --- lustre/mdc/mdc_request.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index e38ac4d09a..800051affd 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -426,29 +426,44 @@ int mdc_req2lustre_md(struct ptlrpc_request *req, int offset, int lmmsize; struct lov_mds_md *lmm; - LASSERT(S_ISREG(md->body->mode)); + if (!S_ISREG(md->body->mode)) { + CERROR("OBD_MD_FLEASIZE set, should be a regular file, " + "but is not\n"); + GOTO(err_out, rc = -EPROTO); + } if (md->body->eadatasize == 0) { CERROR ("OBD_MD_FLEASIZE set, but eadatasize 0\n"); - RETURN(-EPROTO); + GOTO(err_out, rc = -EPROTO); } lmmsize = md->body->eadatasize; lmm = lustre_msg_buf(req->rq_repmsg, offset, lmmsize); - LASSERT (lmm != NULL); + if (!lmm) { + CERROR ("incorrect message: lmm == 0\n"); + GOTO(err_out, rc = -EPROTO); + } LASSERT_REPSWABBED(req, offset); rc = obd_unpackmd(exp, &md->lsm, lmm, lmmsize); if (rc < 0) - RETURN(rc); + GOTO(err_out, rc); - LASSERT (rc >= sizeof (*md->lsm)); + if (rc < sizeof(*md->lsm)) { + CERROR ("lsm size too small: rc < sizeof (*md->lsm) " + "(%d < %d)\n", rc, sizeof(*md->lsm)); + GOTO(err_out, rc = -EPROTO); + } rc = 0; offset++; } if (md->body->valid & OBD_MD_FLDIREA) { - LASSERT(S_ISDIR(md->body->mode)); + if(!S_ISDIR(md->body->mode)) { + CERROR("OBD_MD_FLDIREA set, should be a directory, but " + "is not\n"); + GOTO(err_out, rc = -EPROTO); + } offset++; } -- GitLab