From 333adbc25b0e2acea21cb3e4c79a9401a3157afc Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 18 Mar 2019 13:58:52 +0100 Subject: [PATCH] generator: Don't print any tainted values in DBG3 messages for U_INT_4 The bits not written to are marked tainted by valgrind, don't print them in the debug messages. Also use more specific printf-specifiers for other values. --- src/libcharon/encoding/generator.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcharon/encoding/generator.c b/src/libcharon/encoding/generator.c index 369519b67..f898c87bd 100644 --- a/src/libcharon/encoding/generator.c +++ b/src/libcharon/encoding/generator.c @@ -254,7 +254,7 @@ static void generate_u_int_type(private_generator_t *this, *(this->out_position) = high | low; if (this->debug) { - DBG3(DBG_ENC, " => %d", *(this->out_position)); + DBG3(DBG_ENC, " => %hhu", *(this->out_position) >> 4); } /* write position is not changed, just bit position is moved */ this->current_bit = 4; @@ -268,7 +268,7 @@ static void generate_u_int_type(private_generator_t *this, *(this->out_position) = high | low; if (this->debug) { - DBG3(DBG_ENC, " => %d", *(this->out_position)); + DBG3(DBG_ENC, " => %hhu", *(this->out_position) & 0x0F); } this->out_position++; this->current_bit = 0; @@ -290,7 +290,7 @@ static void generate_u_int_type(private_generator_t *this, *this->out_position = *((uint8_t *)(this->data_struct + offset)); if (this->debug) { - DBG3(DBG_ENC, " => %d", *(this->out_position)); + DBG3(DBG_ENC, " => %hhu", *(this->out_position)); } this->out_position++; break; @@ -318,7 +318,7 @@ static void generate_u_int_type(private_generator_t *this, val = htons(val); if (this->debug) { - DBG3(DBG_ENC, " => %d", val); + DBG3(DBG_ENC, " => %hu", val); } /* write bytes to buffer (set bit is overwritten) */ write_bytes_to_buffer(this, &val, sizeof(uint16_t)); @@ -392,7 +392,7 @@ static void generate_flag(private_generator_t *this, uint32_t offset) *(this->out_position) = *(this->out_position) | flag; if (this->debug) { - DBG3(DBG_ENC, " => %d", *this->out_position); + DBG3(DBG_ENC, " => %hhu", *this->out_position); } this->current_bit++; @@ -412,7 +412,7 @@ static void generate_from_chunk(private_generator_t *this, uint32_t offset) if (this->current_bit != 0) { - DBG1(DBG_ENC, "can not generate a chunk at bitpos %d", + DBG1(DBG_ENC, "can not generate a chunk at bitpos %hhu", this->current_bit); return ; }