Skip to content

Commit 392f0ab

Browse files
committed
Avoid ubsan warning due to memcpy null
This showed up in ext/mysqli/tests/mysqli_change_user.phpt on azure today. Not seeing it locally though, and also not sure why it decided to show up now...
1 parent 3b2410e commit 392f0ab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext/mysqlnd/mysqlnd_wireprotocol.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,9 @@ size_t php_mysqlnd_cached_sha2_result_write(MYSQLND_CONN_DATA * conn, void * _pa
21442144
int1store(buffer + MYSQLND_HEADER_SIZE, '\2');
21452145
sent = pfc->data->m.send(pfc, vio, buffer, 1, stats, error_info);
21462146
} else {
2147-
memcpy(buffer + MYSQLND_HEADER_SIZE, packet->password, packet->password_len);
2147+
if (packet->password_len != 0) {
2148+
memcpy(buffer + MYSQLND_HEADER_SIZE, packet->password, packet->password_len);
2149+
}
21482150
sent = pfc->data->m.send(pfc, vio, buffer, packet->password_len, stats, error_info);
21492151
}
21502152

0 commit comments

Comments
 (0)