Skip to content

Commit

Permalink
Bug#34959429 - Atomic fprofile update [postfix]
Browse files Browse the repository at this point in the history
Problem:
Certain compilation options report the following warning after
Bug#34959429 was merged:

/scratch/mysql/vio/viosslfactories.cc:479:11: note: ‘snprintf’ output
between 2 and 258 bytes into a destination of size 256
 snprintf(tls_version_option, sizeof(tls_version_option), "%s",
 tls_version);

Solution:
Make sure that the entire string (including the NULL terminator) can fit
the tls_version_option buffer.

Change-Id: I2a8d3e11fa689ccc36f4dec95a6a3062c19e092f
  • Loading branch information
stojadin2701 committed Jan 12, 2023
1 parent 3afa837 commit a0cb01f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static long process_tls_version(const char *tls_version) {

if (!tls_version || !xcom_strcasecmp(tls_version, ctx_flag_default)) return 0;

if (strlen(tls_version) - 1 > sizeof(tls_version_option)) return -1;
if (strlen(tls_version) + 1 > sizeof(tls_version_option)) return -1;

snprintf(tls_version_option, sizeof(tls_version_option), "%s", tls_version);
token = xcom_strtok(tls_version_option, separator, &saved_ctx);
Expand Down
2 changes: 1 addition & 1 deletion vio/viosslfactories.cc
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ long process_tls_version(const char *tls_version) {
!my_strcasecmp(&my_charset_latin1, tls_version, ctx_flag_default))
return 0;

if (strlen(tls_version) - 1 > sizeof(tls_version_option)) return -1;
if (strlen(tls_version) + 1 > sizeof(tls_version_option)) return -1;

snprintf(tls_version_option, sizeof(tls_version_option), "%s", tls_version);
token = my_strtok_r(tls_version_option, separator, &lasts);
Expand Down

0 comments on commit a0cb01f

Please sign in to comment.