diff options
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r-- | lib9p/srv.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index befeb6a..6d9d992 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -393,10 +393,7 @@ static void srv_respond_error(struct srv_req *req) { struct srv_sess *sess = req->parent_sess; - /* XXX: This assumes that a version's min_msg_size is the - * Rerror overhead. That's true for the current - * implementation of core_gen, but is a sneaky assumption. */ - uint32_t overhead = lib9p_version_min_msg_size(sess->version); + uint32_t overhead = lib9p_version_min_Rerror_size(sess->version); /* Truncate the error-string if necessary to avoid needing to * return LIB9P_ERRNO_L_ERANGE. */ @@ -748,7 +745,11 @@ static void handle_Tversion(struct srv_req *ctx, #endif } - uint32_t min_msg_size = lib9p_version_min_msg_size(version); + /* XXX: There are good arguments that min_msg_size should be + * something larger than max(rerror.min_size(), + * rread.min_size()+1). */ + uint32_t min_msg_size = _LIB9P_MAX(lib9p_version_min_Rerror_size(ctx->basectx.version), + lib9p_version_min_Rread_size(ctx->basectx.version)+1); if (req->max_msg_size < min_msg_size) { lib9p_errorf(&ctx->basectx, LIB9P_ERRNO_L_EDOM, "requested max_msg_size is less than minimum for %s (%"PRIu32" < %"PRIu32")", @@ -1175,6 +1176,9 @@ static void handle_Tread(struct srv_req *ctx, /* TODO: serialize simultaneous reads to the same FID */ + if (req->count > ctx->basectx.max_msg_size - lib9p_version_min_Rread_size(ctx->basectx.version)) + req->count = ctx->basectx.max_msg_size - lib9p_version_min_Rread_size(ctx->basectx.version); + /* Check that the FID is valid for this. */ struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { @@ -1205,7 +1209,7 @@ static void handle_Tread(struct srv_req *ctx, goto tread_return; } /* Read. */ - resp.data = heap = malloc(req->count); /* TODO: cap req->count */ + resp.data = heap = malloc(req->count); resp.count = 0; struct srv_pathinfo *dir_pathinfo = NULL; for (;;) { |