Bug #86269 PREFER TO USE NULL AS ARG TO REALPATH(), FIXES TEST FAILURE ON ALPINE
Submitted: 10 May 2017 12:38 Modified: 11 May 2017 18:29
Reporter: Terje Røsten Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.2 OS:Any
Assigned to: CPU Architecture:Any

[10 May 2017 12:38] Terje Røsten
Description:
Test main.dd_upgrade_test fails with crash on Alpine. 

Crash was tracked down to my_realpath() and use of realpath() function. 

Reading man 3 realpath 
and POSIX:
 http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html

it seems better to call realpath with second argument as NULL instead of
allocating a buffer of size PATH_MAX.

Using the following patch:

diff --git a/mysys/my_symlink.cc b/mysys/my_symlink.cc
index 3ef244626ef..4162cc0a99b 100644
--- a/mysys/my_symlink.cc
+++ b/mysys/my_symlink.cc
@@ -135,13 +135,16 @@ int my_realpath(char *to, const char *filename, myf MyFlags)
 {
 #ifndef _WIN32
   int result=0;
-  char buff[PATH_MAX];
   char *ptr;
   DBUG_ENTER("my_realpath");
 
   DBUG_PRINT("info",("executing realpath"));
-  if ((ptr=realpath(filename,buff)))
-      strmake(to,ptr,FN_REFLEN-1);
+  ptr = realpath(filename, NULL);
+  if (ptr != NULL)
+  { 
+      strmake(to, ptr, FN_REFLEN-1);
+      free(ptr);
+  }
   else
   {
     /*

main.dd_upgrade_test passes on Alpine. 

Note: not tested on other platforms.

How to repeat:
Run test main.dd_upgrade_test on Alpine host (vide21).

Suggested fix:
Use NULL as second argument to realpath() in my_realpath() in my_symlink.cc
[11 May 2017 18:29] Paul DuBois
Posted by developer:
 
Fixed in 8.0.2.

Bug affects no released version. No changelog entry needed.