Skip to content

Commit ff05239

Browse files
authored
Fix control flow in rb_set_ssl_mode_option for some client library versions (#1088)
MySQL Connector/C 6.1.3 and above configure as HAVE_CONST_MYSQL_OPT_SSL_ENFORCE, but their client library version is a different range than MySQL 5.7.3 - 5.7.10 that also have this option. And generally there's a compiler warning here because of an incomplete control flow if the library version doesn't match and exits the function without an explicit return as required, so add a warning in this case. Closes #1062
1 parent dee108d commit ff05239

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/mysql2/client.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ static VALUE rb_set_ssl_mode_option(VALUE self, VALUE setting) {
113113
#ifdef HAVE_CONST_MYSQL_OPT_SSL_ENFORCE
114114
GET_CLIENT(self);
115115
int val = NUM2INT( setting );
116-
if (version >= 50703 && version < 50711) {
116+
// Either MySQL 5.7.3 - 5.7.10, or Connector/C 6.1.3 - 6.1.x
117+
if ((version >= 50703 && version < 50711) || (version >= 60103 && version < 60200)) {
117118
if (val == SSL_MODE_DISABLED || val == SSL_MODE_REQUIRED) {
118119
my_bool b = ( val == SSL_MODE_REQUIRED );
119120
int result = mysql_options( wrapper->client, MYSQL_OPT_SSL_ENFORCE, &b );
@@ -122,6 +123,9 @@ static VALUE rb_set_ssl_mode_option(VALUE self, VALUE setting) {
122123
rb_warn( "MySQL client libraries between 5.7.3 and 5.7.10 only support SSL_MODE_DISABLED and SSL_MODE_REQUIRED" );
123124
return Qnil;
124125
}
126+
} else {
127+
rb_warn( "Your mysql client library does not support ssl_mode as expected." );
128+
return Qnil;
125129
}
126130
#endif
127131
#ifdef FULL_SSL_MODE_SUPPORT

0 commit comments

Comments
 (0)