diff -Nru mysql-5.0.19/sql/sql_lex.cc mysql-5.0.19-logsec/sql/sql_lex.cc --- mysql-5.0.19/sql/sql_lex.cc 2006-03-04 21:35:19.000000000 +0100 +++ mysql-5.0.19-logsec/sql/sql_lex.cc 2006-04-07 22:33:16.000000000 +0200 @@ -958,6 +958,9 @@ while (lex->ptr != lex->end_of_query && ((c=yyGet()) != '*' || yyPeek() != '/')) { + if (c == '\0') + return(ABORT_SYM); // NULLs illegal even in comments + if (c == '\n') lex->yylineno++; } diff -Naur -Naur mysql-5.0.19.orig/include/my_sys.h mysql-5.0.19.new/include/my_sys.h --- mysql-5.0.19.orig/include/my_sys.h 2006-03-04 20:35:12.000000000 +0000 +++ mysql-5.0.19.new/include/my_sys.h 2006-04-09 17:55:53.000000000 +0000 @@ -599,6 +599,11 @@ const char *sFile, uint uLine, myf MyFlag); +/* implemented in my_memmem.c */ +extern void *my_memmem(const void *haystack, size_t haystacklen, + const void *needle, size_t needlelen); + + #ifdef __WIN__ extern int my_access(const char *path, int amode); extern File my_sopen(const char *path, int oflag, int shflag, int pmode); diff -Naur -Naur mysql-5.0.19.orig/mysys/mf_iocache2.c mysql-5.0.19.new/mysys/mf_iocache2.c --- mysql-5.0.19.orig/mysys/mf_iocache2.c 2006-03-04 20:34:51.000000000 +0000 +++ mysql-5.0.19.new/mysys/mf_iocache2.c 2006-04-09 17:55:53.000000000 +0000 @@ -252,6 +252,10 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) { uint out_length=0; + uint minimum_width; /* as yet unimplemented */ + uint minimum_width_sign; + uint precision; /* as yet unimplemented for anything but %b */ + const char* backtrack; for (; *fmt ; fmt++) { @@ -272,17 +276,53 @@ fmt++; /* Found one '%' */ } + backtrack= fmt; + + minimum_width= 0; + precision= 0; + minimum_width_sign= 1; /* Skip if max size is used (to be compatible with printf) */ - while (my_isdigit(&my_charset_latin1, *fmt) || *fmt == '.' || *fmt == '-') + while (*fmt == '-') { fmt++; minimum_width_sign= -1; } + if (*fmt == '*') { + precision= (int) va_arg(args, int); + fmt++; + } else { + while (my_isdigit(&my_charset_latin1, *fmt)) { + minimum_width=(minimum_width * 10) + (*fmt - '0'); + fmt++; + } + } + minimum_width*= minimum_width_sign; + + if (*fmt == '.') { fmt++; + if (*fmt == '*') { + precision= (int) va_arg(args, int); + fmt++; + } else { + while (my_isdigit(&my_charset_latin1, *fmt)) { + precision=(precision * 10) + (*fmt - '0'); + fmt++; + } + } + } + if (*fmt == 's') /* String parameter */ { reg2 char *par = va_arg(args, char *); uint length = (uint) strlen(par); + /* TODO: implement minimum width and precision */ out_length+=length; if (my_b_write(info, par, length)) goto err; } + else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */ + { + reg2 char *par = va_arg(args, char *); + out_length+=precision; + if (my_b_write(info, par, precision)) + goto err; + } else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */ { register int iarg; @@ -320,6 +360,9 @@ if (my_b_write(info, "%", 1)) goto err; out_length++; + if (my_b_write(info, backtrack, fmt-backtrack)) + goto err; + out_length+= fmt-backtrack; } } return out_length; diff -Naur -Naur mysql-5.0.19.orig/mysys/my_memmem.c mysql-5.0.19.new/mysys/my_memmem.c --- mysql-5.0.19.orig/mysys/my_memmem.c 1970-01-01 00:00:00.000000000 +0000 +++ mysql-5.0.19.new/mysys/my_memmem.c 2006-04-09 17:56:16.000000000 +0000 @@ -0,0 +1,21 @@ +#include "my_base.h" + +/* + * my_memmem, port of a GNU extension. + * + * Returns a pointer to the beginning of the substring, needle, or NULL if the + * substring is not found in haystack. + * */ +void *my_memmem(const void *haystack, size_t haystacklen, + const void *needle, size_t needlelen) +{ + const void *cursor; + const void *end_of_search_beginning = haystack + haystacklen - needlelen; + + for (cursor = haystack; cursor <= end_of_search_beginning; cursor++) { + if (memcmp(needle, cursor, needlelen) == 0) { + return((void *) cursor); + } + } + return(NULL); +} diff -Naur -Naur mysql-5.0.19.orig/sql/sql_parse.cc mysql-5.0.19.new/sql/sql_parse.cc --- mysql-5.0.19.orig/sql/sql_parse.cc 2006-03-04 20:34:48.000000000 +0000 +++ mysql-5.0.19.new/sql/sql_parse.cc 2006-04-09 17:55:53.000000000 +0000 @@ -1710,7 +1710,7 @@ if (alloc_query(thd, packet, packet_length)) break; // fatal error is set char *packet_end= thd->query + thd->query_length; - mysql_log.write(thd,command,"%s",thd->query); + mysql_log.write(thd,command, "%.*b", thd->query_length, thd->query); DBUG_PRINT("query",("%-.4096s",thd->query)); if (!(specialflag & SPECIAL_NO_PRIOR)) diff -Naur -Naur mysql-5.0.19.orig/strings/my_vsnprintf.c mysql-5.0.19.new/strings/my_vsnprintf.c --- mysql-5.0.19.orig/strings/my_vsnprintf.c 2006-03-04 20:34:49.000000000 +0000 +++ mysql-5.0.19.new/strings/my_vsnprintf.c 2006-04-09 17:55:53.000000000 +0000 @@ -27,6 +27,7 @@ %#[l]d %#[l]u %#[l]x + %#.#b Local format; note first # is ignored and second is REQUIRED %#.#s Note first # is ignored RETURN @@ -38,9 +39,18 @@ char *start=to, *end=to+n-1; uint length, width, pre_zero, have_long; + const char *backtrack; + /* + For the special case when we discover that we shouldn't have been + interpreting a percent-format. + + This is here so we can be forgiving about our special local formats. + */ + for (; *fmt ; fmt++) { - if (fmt[0] != '%') + backtrack = fmt; + if (*fmt != '%') { if (to == end) /* End of buffer */ break; @@ -95,6 +105,12 @@ to=strnmov(to,par,plen); continue; } + else if (*fmt == 'b') /* Buffer parameter */ + { + reg2 char *par = va_arg(ap, char *); + to=memmove(to, par, abs(width)); + continue; + } else if (*fmt == 'd' || *fmt == 'u'|| *fmt== 'x') /* Integer parameter */ { register long larg; --- mysql-5.0.19.orig/mysys/Makefile.am 2006-04-17 21:33:44.000000000 +0200 +++ mysql-5.0.19.new/mysys/Makefile.am 2006-04-17 21:36:16.000000000 +0200 @@ -55,6 +55,7 @@ charset.c charset-def.c my_bitmap.c my_bit.c md5.c \ my_gethostbyname.c rijndael.c my_aes.c sha1.c \ my_handler.c my_netware.c my_largepage.c \ + my_memmem.c \ my_windac.c my_access.c base64.c EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ thr_mutex.c thr_rwlock.c --- mysql-5.0.19.orig/mysys/Makefile.in 2006-04-17 21:36:59.000000000 +0200 +++ mysql-5.0.19.new/mysys/Makefile.in 2006-04-17 21:37:52.000000000 +0200 @@ -514,6 +514,7 @@ charset.c charset-def.c my_bitmap.c my_bit.c md5.c \ my_gethostbyname.c rijndael.c my_aes.c sha1.c \ my_handler.c my_netware.c my_largepage.c \ + my_memmem.c \ my_windac.c my_access.c base64.c EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \