~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/date.cc

Change temporal to_string routines to use snprintf instead of sprintf.
Also change length parameter to be length of string to write to, and
add return value of length written (or what would have - i.e. snprintf
result).

This doesn't fix https://bugs.launchpad.net/drizzle/+bug/373468 but
it means we hit an assert() on being able to put the temporal type
into a string instead of overwriting the buffer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
  }
39
39
 
40
40
  /* Convert the Date to a string and return it */
41
 
  size_t new_length;
42
 
  temporal.to_string(str->c_ptr(), &new_length);
43
 
  str->length((uint32_t) new_length);
 
41
  int new_length;
 
42
  new_length= temporal.to_string(str->c_ptr(), MAX_DATE_STRING_REP_LENGTH);
 
43
  assert(new_length < MAX_DATE_STRING_REP_LENGTH);
 
44
  str->length(new_length);
44
45
  return str;
45
46
}
46
47