From d5e83152908078b2a5736a4513f8a96b2929f912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 31 May 2019 06:53:19 +0300 Subject: [PATCH] Assert that buffers are non-null in mysql.h The functions assume that the buffer is never null and thus should be asserted. --- include/maxscale/protocol/mysql.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/maxscale/protocol/mysql.h b/include/maxscale/protocol/mysql.h index 02b6c9d10..350efe07d 100644 --- a/include/maxscale/protocol/mysql.h +++ b/include/maxscale/protocol/mysql.h @@ -379,6 +379,7 @@ static inline uint32_t MYSQL_GET_PAYLOAD_LEN(const uint8_t* header) static inline uint32_t MYSQL_GET_PACKET_LEN(const GWBUF* buffer) { + mxb_assert(buffer); return MYSQL_GET_PAYLOAD_LEN(GWBUF_DATA(buffer)) + MYSQL_HEADER_LEN; } @@ -629,6 +630,7 @@ void mxs_mysql_set_current_db(MXS_SESSION* session, const char* db); */ static inline uint8_t mxs_mysql_get_command(GWBUF* buffer) { + mxb_assert(buffer); if (GWBUF_LENGTH(buffer) > MYSQL_HEADER_LEN) { return GWBUF_DATA(buffer)[4]; @@ -652,6 +654,7 @@ static inline uint8_t mxs_mysql_get_command(GWBUF* buffer) */ static inline uint32_t mxs_mysql_get_packet_len(GWBUF* buffer) { + mxb_assert(buffer); // The first three bytes of the packet header contain its length uint8_t buf[3]; gwbuf_copy_data(buffer, 0, 3, buf);