diff options
author | Nisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com> | 2014-04-24 09:30:21 +0530 |
---|---|---|
committer | Nisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com> | 2014-04-24 09:30:21 +0530 |
commit | 501de3a027f11e33c14136f83e45dabe3d6f3102 (patch) | |
tree | 61c49e35855f044c9d61edc9b90ee4526a0cf3fa /include/errmsg.h | |
parent | c76e29c88415fbb381893f70cd7a9865cd49ee25 (diff) | |
download | mariadb-git-501de3a027f11e33c14136f83e45dabe3d6f3102.tar.gz |
BUG#18080920: CRASH; MY_REALLOC_STR DEREFERENCES NEGATIVE VALUE
INTO CLIENT_ERRORS ARRAY
Analysis:
--------
The client may crash while executing a statement due to
the missing mapping of the server error to it's equivalent
client error.
When trying to reallocate memory for the packet buffer, if
the system is out of memory or the packet buffer is large,
the server errors 'ER_OUT_OF_RESOURCES' or 'ER_PACKET_TOO_LARGE'
is returned respectively. The client error number calculated is
negative and when trying to dereference the array of client
error messages with the calculated error number, the client
crashes.
Fix:
----
Map the server error returned to it's equivalent client error
prior to dereferencing the array of client error messages.
Note: Test case is not added since it is difficult to simulate
the error condition.
Diffstat (limited to 'include/errmsg.h')
-rw-r--r-- | include/errmsg.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/errmsg.h b/include/errmsg.h index 64ec2df395c..5655883466c 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -1,7 +1,7 @@ #ifndef ERRMSG_INCLUDED #define ERRMSG_INCLUDED -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,7 +32,9 @@ extern const char *client_errors[]; /* Error messages */ #define CR_MIN_ERROR 2000 /* For easier client code */ #define CR_MAX_ERROR 2999 #if !defined(ER) -#define ER(X) client_errors[(X)-CR_MIN_ERROR] +#define ER(X) (((X) >= CR_ERROR_FIRST && (X) <= CR_ERROR_LAST)? \ + client_errors[(X)-CR_ERROR_FIRST]: client_errors[CR_UNKNOWN_ERROR]) + #endif #define CLIENT_ERRMAP 2 /* Errormap used by my_error() */ |