Commit 0fcdce7b authored by monty@donna.mysql.com's avatar monty@donna.mysql.com

Fix for snprintf

parent 84b93976
...@@ -222,8 +222,6 @@ inline double ulonglong2double(ulonglong value) ...@@ -222,8 +222,6 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_PERROR #define HAVE_PERROR
#define HAVE_VFPRINT #define HAVE_VFPRINT
#define HAVE_SNPRINTF
#define _snprintf snprintf
#define HAVE_CHSIZE /* System has chsize() function */ #define HAVE_CHSIZE /* System has chsize() function */
#define HAVE_RENAME /* Have rename() as function */ #define HAVE_RENAME /* Have rename() as function */
#define HAVE_BINARY_STREAMS /* Have "b" flag in streams */ #define HAVE_BINARY_STREAMS /* Have "b" flag in streams */
...@@ -248,6 +246,11 @@ inline double ulonglong2double(ulonglong value) ...@@ -248,6 +246,11 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_ALLOCA #define HAVE_ALLOCA
#define HAVE_COMPRESS #define HAVE_COMPRESS
#ifdef NOT_USED
#define HAVE_SNPRINTF /* Gave link error */
#define _snprintf snprintf
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */ #define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
#define HAVE_ANSI_INCLUDE #define HAVE_ANSI_INCLUDE
......
...@@ -501,7 +501,8 @@ void Field_decimal::store(double nr) ...@@ -501,7 +501,8 @@ void Field_decimal::store(double nr)
fyllchar = zerofill ? (char) '0' : (char) ' '; fyllchar = zerofill ? (char) '0' : (char) ' ';
#ifdef HAVE_SNPRINTF_ #ifdef HAVE_SNPRINTF_
snprintf(buff,sizeof(buff), "%.*f",(int) dec,nr); buff[sizeof(buff)-1]=0; // Safety
snprintf(buff,sizeof(buff)-1, "%.*f",(int) dec,nr);
#else #else
sprintf(buff,"%.*f",dec,nr); sprintf(buff,"%.*f",dec,nr);
#endif #endif
...@@ -2075,7 +2076,8 @@ String *Field_double::val_str(String *val_buffer, ...@@ -2075,7 +2076,8 @@ String *Field_double::val_str(String *val_buffer,
*to++= *pos++; *to++= *pos++;
#else #else
#ifdef HAVE_SNPRINTF #ifdef HAVE_SNPRINTF
snprintf(to,to_length,"%.*f",dec,nr); buff[to_length-1]=0; // Safety
snprintf(to,to_length-1,"%.*f",dec,nr);
#else #else
sprintf(to,"%.*f",dec,nr); sprintf(to,"%.*f",dec,nr);
#endif #endif
......
...@@ -359,7 +359,8 @@ void field_real::add() ...@@ -359,7 +359,8 @@ void field_real::add()
else else
{ {
#ifdef HAVE_SNPRINTF #ifdef HAVE_SNPRINTF
snprintf(buff, sizeof(buff), "%-.*f", (int) decs, num); buff[sizeof(buff)-1]=0; // Safety
snprintf(buff, sizeof(buff)-1, "%-.*f", (int) decs, num);
#else #else
sprintf(buff, "%-.*f", (int) decs, num); sprintf(buff, "%-.*f", (int) decs, num);
#endif #endif
......
...@@ -186,7 +186,8 @@ end: ...@@ -186,7 +186,8 @@ end:
return FALSE; return FALSE;
#else #else
#ifdef HAVE_SNPRINTF #ifdef HAVE_SNPRINTF
snprintf(buff,sizeof(buff), "%.*f",(int) decimals,num); buff[sizeof(buff)-1]=0; // Safety
snprintf(buff,sizeof(buff)-1, "%.*f",(int) decimals,num);
#else #else
sprintf(buff,"%.*f",(int) decimals,num); sprintf(buff,"%.*f",(int) decimals,num);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment