Skip to content
  • Karthik Kamath's avatar
    cf3a1d4f
    BUG#26136674: POSSIBLE UNINTENDED USAGE OF "PRECISION" · cf3a1d4f
    Karthik Kamath authored
                  VARIABLE
    
    ANALYSIS:
    =========
    In the function my_b_vprintf() which is used for logging
    in MySQL, there is an unintended usage of 'precision'
    variable.
    
    my_b_printf() which is wrapper for my_b_vprintf() is a
    simple version of printf().
    Generally in printf() statements, we use an asterisk (*) to
    denote the width specifier/precision instead of hard coding
    it in the format string. The value for '*' is passed as an
    additional integer value argument to printf(), preceding
    the argument that has to be formatted.
    
    To achieve the required formatting, we use two variables
    which are defined below.
    
    - minimum_width (currently implemented for %d and %u):
      The minimum number of characters to be printed. If the
      value to be printed is shorter than this number, the
      result is padded with blank spaces.
    
    - precision (currently implemented for %b, binary buffer):
      used to print exactly <precision> bytes from the argument
      without stopping at '\0'.
    
    In the current implementation, 'precision' was used for
    processing '*' which should ideally be used only for
    processing '.*'. This might result in data loss.
    
    FIX:
    ====
    We are now using the variable 'precision' for processing
    of '.*' and 'minimum_width' for processing of '*'.
    cf3a1d4f
    BUG#26136674: POSSIBLE UNINTENDED USAGE OF "PRECISION"
    Karthik Kamath authored
                  VARIABLE
    
    ANALYSIS:
    =========
    In the function my_b_vprintf() which is used for logging
    in MySQL, there is an unintended usage of 'precision'
    variable.
    
    my_b_printf() which is wrapper for my_b_vprintf() is a
    simple version of printf().
    Generally in printf() statements, we use an asterisk (*) to
    denote the width specifier/precision instead of hard coding
    it in the format string. The value for '*' is passed as an
    additional integer value argument to printf(), preceding
    the argument that has to be formatted.
    
    To achieve the required formatting, we use two variables
    which are defined below.
    
    - minimum_width (currently implemented for %d and %u):
      The minimum number of characters to be printed. If the
      value to be printed is shorter than this number, the
      result is padded with blank spaces.
    
    - precision (currently implemented for %b, binary buffer):
      used to print exactly <precision> bytes from the argument
      without stopping at '\0'.
    
    In the current implementation, 'precision' was used for
    processing '*' which should ideally be used only for
    processing '.*'. This might result in data loss.
    
    FIX:
    ====
    We are now using the variable 'precision' for processing
    of '.*' and 'minimum_width' for processing of '*'.
Loading