diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index f3e89defd..6f6785c2e 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -40,6 +40,7 @@ #include #include #include +#include #ifndef __has_feature # define __has_feature(x) 0 @@ -1811,6 +1812,20 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, /* Check if server sends an error */ if (mysql->protocol_version == 0XFF) { + /* This code appears to be unreachable. + * + * 1. `if (mysql->protocol_version == 0XFF)` is checking the first + * byte of the packet received by `ma_net_safe_read` above. + * 2. But if the first byte of the packet body received by + * `ma_net_safe_read` had been 0xff, then `ma_net_safe_read` + * would have returned `packet_error`. + * (See its source above, in this same file.) + * 3. Therefore, we would have taken the above branch + * (`if (ma_net_safe_read(mysql) == packet_error)`), and jumped + * straight to `goto error`, skipping this section. + */ + MY_ASSERT_UNREACHABLE(); + net_get_error(end, pkt_length - 1, net->last_error, sizeof(net->last_error), &net->last_errno, net->sqlstate); /* fix for bug #26426 */