diff options
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r-- | sql/protocol.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc index e14eafc86a2..bceac780037 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -213,11 +213,13 @@ net_printf(THD *thd, uint errcode, ...) 2+SQLSTATE_LENGTH+1 : 2) : 0); #ifndef EMBEDDED_LIBRARY text_pos=(char*) net->buff + head_length + offset + 1; + length= (uint) ((char*)net->buff_end - text_pos); +#else + length=sizeof(text_pos)-1; #endif - (void) vsprintf(my_const_cast(char*) (text_pos),format,args); - length=(uint) strlen((char*) text_pos); - if (length >= sizeof(net->last_error)) - length=sizeof(net->last_error)-1; /* purecov: inspected */ + length=my_vsnprintf(my_const_cast(char*) (text_pos), + min(length, sizeof(net->last_error)), + format,args); va_end(args); #ifndef EMBEDDED_LIBRARY |