diff --git a/server/modules/filter/masking/maskingfiltersession.cc b/server/modules/filter/masking/maskingfiltersession.cc index 6c86fda2f..6e7b32b6b 100644 --- a/server/modules/filter/masking/maskingfiltersession.cc +++ b/server/modules/filter/masking/maskingfiltersession.cc @@ -191,12 +191,6 @@ void MaskingFilterSession::handle_row(GWBUF* pPacket) m_state = EXPECTING_NOTHING; break; - case 0xfb: // NULL is sent as 0xfb - MXS_NOTICE("NULL"); - // We must ask for the rule so as not to get out of sync. - m_res.get_rule(); - break; - default: { ComQueryResponse::Row row(response); @@ -210,7 +204,10 @@ void MaskingFilterSession::handle_row(GWBUF* pPacket) { LEncString s = *i; - pRule->rewrite(s); + if (!s.is_null()) + { + pRule->rewrite(s); + } MXS_NOTICE("String: %s", (*i).to_string().c_str()); } diff --git a/server/modules/filter/masking/mysql.hh b/server/modules/filter/masking/mysql.hh index 3f22a0798..56eba66c2 100644 --- a/server/modules/filter/masking/mysql.hh +++ b/server/modules/filter/masking/mysql.hh @@ -213,7 +213,16 @@ public: */ LEncString(uint8_t* pData) { - m_pString = mxs_lestr_consume(&pData, &m_length); + // NULL is sent as 0xfb. See https://dev.mysql.com/doc/internals/en/com-query-response.html + if (*pData != 0xfb) + { + m_pString = mxs_lestr_consume(&pData, &m_length); + } + else + { + m_pString = NULL; + m_length = 0; + } } /** @@ -225,7 +234,17 @@ public: */ LEncString(uint8_t** ppData) { - m_pString = mxs_lestr_consume(ppData, &m_length); + // NULL is sent as 0xfb. See https://dev.mysql.com/doc/internals/en/com-query-response.html + if (**ppData != 0xfb) + { + m_pString = mxs_lestr_consume(ppData, &m_length); + } + else + { + m_pString = NULL; + m_length = 0; + ++(*ppData); + } } /** @@ -301,7 +320,14 @@ public: */ std::string to_string() const { - return std::string(m_pString, m_length); + if (m_pString) + { + return std::string(m_pString, m_length); + } + else + { + return std::string("NULL"); + } } /** @@ -317,6 +343,16 @@ public: return o; } + /** + * Is NULL + * + * @return True, if the string represents a NULL value. + */ + bool is_null() const + { + return m_pString == NULL; + } + private: char* m_pString; /*