Commit 2090bc6e authored by unknown's avatar unknown

Fixed bug in memory allocation that could affect 64 bit systems (affected hammer)


mysys/my_vsnprintf.c:
  safety fix
sql/log.cc:
  safety fix
parent 68fc04c4
...@@ -21,13 +21,18 @@ ...@@ -21,13 +21,18 @@
#include <stdarg.h> #include <stdarg.h>
#include <m_ctype.h> #include <m_ctype.h>
int my_snprintf(char* to, size_t n, const char* fmt, ...) int my_snprintf(char* to, size_t n, const char* fmt, ...)
{ {
int result;
va_list args; va_list args;
va_start(args,fmt); va_start(args,fmt);
return my_vsnprintf(to, n, fmt, args); result= my_vsnprintf(to, n, fmt, args);
va_end(args);
return result;
} }
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
{ {
char *start=to, *end=to+n-1; char *start=to, *end=to+n-1;
...@@ -79,6 +84,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) ...@@ -79,6 +84,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
return (uint) (to - start); return (uint) (to - start);
} }
#ifdef MAIN #ifdef MAIN
static void my_printf(const char * fmt, ...) static void my_printf(const char * fmt, ...)
{ {
...@@ -92,6 +98,7 @@ static void my_printf(const char * fmt, ...) ...@@ -92,6 +98,7 @@ static void my_printf(const char * fmt, ...)
va_end(ar); va_end(ar);
} }
int main() int main()
{ {
......
...@@ -953,7 +953,7 @@ int ha_myisam::create(const char *name, register TABLE *form, ...@@ -953,7 +953,7 @@ int ha_myisam::create(const char *name, register TABLE *form,
&keydef, form->keys*sizeof(MI_KEYDEF), &keydef, form->keys*sizeof(MI_KEYDEF),
&keyseg, &keyseg,
((form->key_parts + form->keys) * sizeof(MI_KEYSEG)), ((form->key_parts + form->keys) * sizeof(MI_KEYSEG)),
0))) NullS)))
DBUG_RETURN(1); DBUG_RETURN(1);
pos=form->key_info; pos=form->key_info;
......
...@@ -1067,6 +1067,7 @@ void sql_print_error(const char *format,...) ...@@ -1067,6 +1067,7 @@ void sql_print_error(const char *format,...)
char buff[1024]; char buff[1024];
my_vsnprintf(buff,sizeof(buff)-1,format,args); my_vsnprintf(buff,sizeof(buff)-1,format,args);
DBUG_PRINT("error",("%s",buff)); DBUG_PRINT("error",("%s",buff));
va_end(args);
va_start(args,format); va_start(args,format);
} }
#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