diff options
Diffstat (limited to 'lib9p/types.c')
-rw-r--r-- | lib9p/types.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib9p/types.c b/lib9p/types.c index 5b6d0a0..071e3c8 100644 --- a/lib9p/types.c +++ b/lib9p/types.c @@ -83,10 +83,10 @@ static inline bool checksize_stat(struct _checksize_ctx *ctx) { || checksize_s(ctx) || checksize_s(ctx) || checksize_s(ctx) - || ( ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) && checksize_s(ctx) ) - || ( ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) && checksize_4(ctx) ) - || ( ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) && checksize_4(ctx) ) - || ( ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) && checksize_4(ctx) ); + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_s(ctx) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_4(ctx) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_4(ctx) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_4(ctx) ); } static bool checksize_Tversion(struct _checksize_ctx *ctx) { @@ -103,7 +103,7 @@ static bool checksize_Tauth(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_s(ctx) || checksize_s(ctx) - || ( ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) && checksize_4(ctx) ); + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_4(ctx) ); } static bool checksize_Rauth(struct _checksize_ctx *ctx) { @@ -123,7 +123,7 @@ static bool checksize_Rattach(struct _checksize_ctx *ctx) { static bool checksize_Rerror(struct _checksize_ctx *ctx) { return checksize_s(ctx) - || ( ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) && checksize_4(ctx) ); + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_4(ctx) ); } static bool checksize_Tflush(struct _checksize_ctx *ctx) { @@ -521,7 +521,7 @@ static void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rswri /* marshal_* ******************************************************************/ static inline bool _marshal_too_large(struct _marshal_ctx *ctx) { - lib9p_errorf(ctx->ctx, LINUX_EMSGSIZE, "%s too large to marshal into %s limit (limit=%"PRIu32")", + lib9p_errorf(ctx->ctx, LINUX_ERANGE, "%s too large to marshal into %s limit (limit=%"PRIu32")", (ctx->net_bytes[4] % 2 == 0) ? "T-message" : "R-message", ctx->ctx->version ? "negotiated" : ((ctx->net_bytes[4] % 2 == 0) ? "client" : "server"), ctx->ctx->max_msg_size); @@ -599,10 +599,10 @@ static inline bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val || marshal_s(ctx, &val->file_owner_uid) || marshal_s(ctx, &val->file_owner_gid) || marshal_s(ctx, &val->file_last_modified_uid) - || marshal_s(ctx, &val->file_extension) - || marshal_4(ctx, &val->file_owner_n_uid) - || marshal_4(ctx, &val->file_owner_n_gid) - || marshal_4(ctx, &val->file_last_modified_n_uid); + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_s(ctx, &val->file_extension) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_uid) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_gid) ) + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_last_modified_n_uid) ); } static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *val) { @@ -619,7 +619,7 @@ static bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tauth *val) return marshal_4(ctx, &val->afid) || marshal_s(ctx, &val->uname) || marshal_s(ctx, &val->aname) - || marshal_4(ctx, &val->n_uname); + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) ); } static bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rauth *val) { @@ -638,8 +638,11 @@ static bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_Rattach * } static bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Rerror *val) { + /* Truncate the error-string if necessary to avoid returning ERANGE. */ + if (((uint32_t)val->ename.len) + ctx->ctx->Rerror_overhead > ctx->ctx->max_msg_size) + val->ename.len = ctx->ctx->max_msg_size - ctx->ctx->Rerror_overhead; return marshal_s(ctx, &val->ename) - || marshal_4(ctx, &val->errno); + || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->errno) ); } static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) { |