Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-07-09 17:53:52+03:00, gkodinov@stripped +2 -0
Bug #29469: Client dies if a query is issued after hitting Ctrl + C
The Ctrl-C handler in mysql closes the console while ReadConsole()
waits for console input.
But the main thread was detecting that ReadConsole() haven't read
anything and was processing as if there're data in the buffer.
Fixed to handle correctly this error condition.
No test case added as the test relies on Ctrl-C sent to the client
from its console.
client/mysql.cc@stripped, 2007-07-09 17:53:51+03:00, gkodinov@stripped +6 -1
Bug #29469: handle correctly console read error
mysys/my_conio.c@stripped, 2007-07-09 17:53:51+03:00, gkodinov@stripped +5 -2
Bug #29469:
1. handle correctly console read error
2. add boundry checks for console buffer.
diff -Nrup a/client/mysql.cc b/client/mysql.cc
--- a/client/mysql.cc 2007-04-23 17:21:59 +03:00
+++ b/client/mysql.cc 2007-07-09 17:53:51 +03:00
@@ -1086,7 +1086,12 @@ static int read_and_execute(bool interac
something else is still in console input buffer
*/
} while (tmpbuf.alloced_length() <= clen);
- line= buffer.c_ptr();
+ /*
+ An empty like is returned from my_cgets when there's error reading :
+ Ctrl-c for example
+ */
+ if (line)
+ line= buffer.c_ptr();
#else /* OS2 */
buffer.length(0);
/* _cgets() expects the buffer size - 3 as the first byte */
diff -Nrup a/mysys/my_conio.c b/mysys/my_conio.c
--- a/mysys/my_conio.c 2006-12-23 21:04:07 +02:00
+++ b/mysys/my_conio.c 2007-07-09 17:53:51 +03:00
@@ -184,16 +184,19 @@ char* my_cgets(char *buffer, unsigned lo
}
while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY);
+ /* We go here on error reading the string (Ctrl-C for example) */
+ if (!*plen)
+ result= NULL; /* purecov: inspected */
if (result != NULL)
{
- if (buffer[*plen - 2] == '\r')
+ if (*plen > 1 && buffer[*plen - 2] == '\r')
{
*plen= *plen - 2;
}
else
{
- if (buffer[*plen - 1] == '\r')
+ if (*plen > 0 && buffer[*plen - 1] == '\r')
{
char tmp[3];
int tmplen= sizeof(tmp);
| Thread |
|---|
| • bk commit into 5.0 tree (gkodinov:1.2525) BUG#29469 | kgeorge | 9 Jul |