Skip to content

Commit d3b0f81

Browse files
author
Aditya A
committed
Bug #28178776 COMPARISON OF UNINITAILIZED MEMORY IN LOG_IN_USE
PROBLEM ------- Memory sanitizer reports uninitialized comparisons in log_in_use(), because strings are compared with memcmp() instead of strncmp. FIX --- Use strncmp() to compare strings
1 parent 78e067e commit d3b0f81

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sql/log.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -3407,7 +3407,7 @@ int MYSQL_BIN_LOG::find_log_pos(LOG_INFO *linfo, const char *log_name,
34073407
// if the log entry matches, null string matching anything
34083408
if (!log_name ||
34093409
(log_name_len == fname_len-1 && full_fname[log_name_len] == '\n' &&
3410-
!memcmp(full_fname, full_log_name, log_name_len)))
3410+
!strncmp(full_fname, full_log_name, log_name_len)))
34113411
{
34123412
DBUG_PRINT("info", ("Found log file entry"));
34133413
full_fname[fname_len-1]= 0; // remove last \n

sql/sql_repl.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -261,7 +261,7 @@ bool log_in_use(const char* log_name)
261261
if ((linfo = tmp->current_linfo))
262262
{
263263
mysql_mutex_lock(&linfo->lock);
264-
result = !memcmp(log_name, linfo->log_file_name, log_name_len);
264+
result = !strncmp(log_name, linfo->log_file_name, log_name_len);
265265
mysql_mutex_unlock(&linfo->lock);
266266
if (result)
267267
break;

0 commit comments

Comments
 (0)