From 5058fb280347f602766ffa06c0274899825a4f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCdemann?= Date: Fri, 3 Feb 2017 19:58:18 +0100 Subject: [PATCH] add explicit undef value to format string enums This lead to uninitialized read of length_modifier and representation. While probably not critical, as the respective switches contain a default branch and the compiler seems to allow integral values outside the enum range. --- src/goto-programs/format_strings.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/goto-programs/format_strings.h b/src/goto-programs/format_strings.h index 157a8bf96f4..552e3c91b5e 100644 --- a/src/goto-programs/format_strings.h +++ b/src/goto-programs/format_strings.h @@ -30,12 +30,29 @@ class format_tokent typedef enum { ALTERNATE, ZERO_PAD, LEFT_ADJUST, SIGNED_SPACE, SIGN, ASTERISK } flag_typet; - typedef enum { LEN_h, LEN_hh, LEN_l, LEN_ll, LEN_L, LEN_j, LEN_t } length_modifierst; + typedef enum + { + LEN_undef, LEN_h, LEN_hh, LEN_l, LEN_ll, + LEN_L, LEN_j, LEN_t + } length_modifierst; + + typedef enum + { + SIGNED_undef, SIGNED_DEC, UNSIGNED_DEC, + UNSIGNED_OCT, UNSIGNED_HEX + } representationt; + + explicit format_tokent(token_typet _type) + : type(_type), + length_modifier(LEN_undef), + representation(SIGNED_undef) + { } + format_tokent(): + type(UNKNOWN), + length_modifier(LEN_undef), + representation(SIGNED_undef) + { } - typedef enum { SIGNED_DEC, UNSIGNED_DEC, UNSIGNED_OCT, UNSIGNED_HEX } representationt; - - explicit format_tokent(token_typet _type) : type(_type) { } - format_tokent(): type(UNKNOWN) { } token_typet type; std::list flags;