[CONC-400] error with sizeof("commit") in function mysql_commit Created: 2019-03-27 Updated: 2020-02-02 Resolved: 2020-02-02 |
|
| Status: | Closed |
| Project: | MariaDB Connector/C |
| Component/s: | None |
| Affects Version/s: | 2.3.7 |
| Fix Version/s: | 3.1.3 |
| Type: | Bug | Priority: | Minor |
| Reporter: | anklean | Assignee: | Georg Richter |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
linux ppc64/window10 x64 |
||
| Description |
|
Hi team,
I found that the mysql_commit function uses the sizeof("commit") , the value is 7.
and the libmysql.c in library mysql-5.5.37/libmysql ,the implement is
when i use libmysql, the error is fixed. the poco c++ library use length() function ,and the error is fixed too.
I'm not sure if it's a bug, so I want to get an answer. |
| Comments |
| Comment by Pali [ 2019-06-18 ] | ||
|
sizeof("COMMIT") is 7 and strlen("COMMIT") is 6 by definition of C language. 6 is length of string "COMMIT" and 7 is size of buffer needed for storing null-term string "COMMIT. According to both MariaDB and MySQL documentation of mysql_real_query() function, caller should pass length of string in bytes and not size of needed for storing null-term string. See: https://mariadb.com/kb/en/library/mysql_real_query/ So correct implementation should use either
or
So, could you fix current implementation of mysql_commit and mysql_rollback? | ||
| Comment by anklean [ 2019-06-19 ] | ||
|
ok,i'd like to fix it | ||
| Comment by Pali [ 2020-02-02 ] | ||
|
anklean: Are you going to fix it? It should be really simple, just adds -1 after sizeof(). | ||
| Comment by Georg Richter [ 2020-02-02 ] | ||
|
This was already fixed: Merge pull request #115 from anklean/3.1 fix bug | ||
| Comment by Pali [ 2020-02-02 ] | ||
|
Great! I did not know that this was already fixed as in this issue was still in open state and there was no update. |