Skip to content

Commit

Permalink
MDEV-15734 - calculation inside sizeof() warning
Browse files Browse the repository at this point in the history
Reverted incorrect change introduced by 548d03d.

As result is char**, third qsort() parameter must be sizeof(char*).
Not sizeof(result[0] + 2), which is same as sizeof(result[0]).
Not even sizeof(result[0]) + 2, which would cause invalid memory access.

Proper sorting is responsibility of logfilenamecompare() callback.
  • Loading branch information
Sergey Vojtovich committed May 30, 2019
1 parent 78c1be8 commit dd939d6
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions storage/tokudb/PerconaFT/ft/logger/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,8 @@ int toku_logger_find_logfiles (const char *directory, char ***resultp, int *n_lo
snprintf(fname, fnamelen, "%s/%s", directory, de->d_name);
result[n_results++] = fname;
}
// Return them in increasing order. Set width to allow for newer log file names ("xxx.tokulog13")
// which are one character longer than old log file names ("xxx.tokulog2"). The comparison function
// won't look beyond the terminating NUL, so an extra character in the comparison string doesn't matter.
// Allow room for terminating NUL after "xxx.tokulog13" even if result[0] is of form "xxx.tokulog2."
int width = sizeof(result[0]+2);
qsort(result, n_results, width, logfilenamecompare);
// Return them in increasing order.
qsort(result, n_results, sizeof(result[0]), logfilenamecompare);
*resultp = result;
*n_logfiles = n_results;
result[n_results]=0; // make a trailing null
Expand Down

0 comments on commit dd939d6

Please sign in to comment.