generator: Don't print any tainted values in DBG3 messages for U_INT_4
authorTobias Brunner <tobias@strongswan.org>
Mon, 18 Mar 2019 12:58:52 +0000 (13:58 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 27 Mar 2019 09:00:09 +0000 (10:00 +0100)
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

index 369519b..f898c87 100644 (file)
@@ -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 ;
        }