~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/timestamp.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:
230
230
{
231
231
  uint32_t temp;
232
232
  char *to;
 
233
  int to_len= field_length + 1;
233
234
 
234
 
  val_buffer->alloc(field_length + 1);
 
235
  val_buffer->alloc(to_len);
235
236
  to= (char *) val_buffer->ptr();
236
237
 
237
238
#ifdef WORDS_BIGENDIAN
245
246
 
246
247
  drizzled::Timestamp temporal;
247
248
  (void) temporal.from_time_t((time_t) temp);
248
 
  size_t to_len;
249
 
 
250
 
  temporal.to_string(to, &to_len);
251
 
  val_buffer->length((uint32_t) to_len);
 
249
 
 
250
  int rlen;
 
251
  rlen= temporal.to_string(to, to_len);
 
252
  assert(rlen < to_len);
 
253
 
 
254
  val_buffer->length(to_len);
252
255
  return val_buffer;
253
256
}
254
257