Bug #6079 sjis charset data escaping problem

Submitted: 13 Oct 2004 23:56 Modified: 12 Nov 2004 3:13
Reporter: Peter Zaitsev (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0 OS:Any (all)
Assigned to: CPU Architecture:Any

[13 Oct 2004 23:56] Peter Zaitsev
Description:
We have problems in escaping BLOB fields if  when "sjis" charset is used.

How to repeat:
/etc/my.cnf

[sjis]
default-character-set   = sjis

==========

mysql> create table a (a blob);

==========
test.c

#include <stdio.h>
#include <string.h>
#include <mysql/mysql.h>

int main()
{
   MYSQL *mysql, *con;
   MYSQL_RES   *res;
   MYSQL_ROW    row, end_row;
   int r, i;
   char buf[1024], *end;
   unsigned char val[] = {0x7E, 0x00, 0x7F, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00 };

   mysql = mysql_init(NULL);
   if (NULL == mysql)   {      goto label1;   }

   mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "sjis");

   con = mysql_real_connect(mysql, NULL, "root", NULL, "s", 0, NULL, 0);

   if (NULL == con)   {      goto label1;   }

   end = buf;
   bcopy("INSERT INTO a VALUES (",  buf, 22);   end = end + 22;
   *end = '\''; end++;
   end += mysql_real_escape_string(mysql, end, val, 10);
   *end = '\''; end++;
   *end = ')'; end++;

   r = mysql_real_query(mysql, buf, (unsigned int) (end - buf) );

   mysql_close(mysql);

   return 0;

 label1:
   return 1;
}

==========
hexdump after exec test.c

root@debian /var/mysql/data/s # hex a.MYD
0x00000000: 03 00 10 00 00 fe 0c 00 - 7e 00 7f 00 80 00 81 5c C@P@@.L@~@?@.@.\
0x00000010: 30 82 5c 30             -                         0.\0
[12 Nov 2004 3:13] MySQL Verification Team
According Bar this was already fixed. See internal notes.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.