Fixed potential overflow and fixed the state stack to be at least 32 bits

This commit is contained in:
Snaipe 2016-01-15 13:51:10 +01:00
parent e4ee92c8d7
commit a6aefb69aa
2 changed files with 3 additions and 3 deletions

View file

@ -331,7 +331,7 @@ bool handle_timeout(struct server_ctx *sctx, struct client_ctx *ctx, const crite
return false;
}
# define MAX_TEST_DEPTH 15
# define MAX_TEST_DEPTH 16
bool handle_phase(struct server_ctx *sctx, struct client_ctx *ctx, const criterion_protocol_msg *msg) {
const criterion_protocol_phase *phase_msg = &msg->data.value.phase;
@ -347,7 +347,7 @@ bool handle_phase(struct server_ctx *sctx, struct client_ctx *ctx, const criteri
handler_error(sctx, "%s: ", id, "Cannot spawn a subtest outside of the '%s' test phase.", state_to_string[CS_MAIN]);
return true;
}
if (ctx->state & (0xff << MAX_TEST_DEPTH * 2)) {
if (ctx->state & (0x3 << (MAX_TEST_DEPTH - 1) * 2)) {
char id[32];
get_message_id(id, sizeof (id), msg);

View file

@ -53,7 +53,7 @@ struct client_ctx {
struct criterion_test_extra_data extern_test_data;
struct criterion_test extern_test;
enum client_state state;
uint32_t state;
bool alive;
struct criterion_global_stats *gstats;
struct criterion_suite_stats *sstats;