diff options
Diffstat (limited to 'ext/mysql/libmysql/mf_format.c')
| -rw-r--r-- | ext/mysql/libmysql/mf_format.c | 18 | 
1 files changed, 14 insertions, 4 deletions
diff --git a/ext/mysql/libmysql/mf_format.c b/ext/mysql/libmysql/mf_format.c index 59056b2766..72971ed318 100644 --- a/ext/mysql/libmysql/mf_format.c +++ b/ext/mysql/libmysql/mf_format.c @@ -17,12 +17,17 @@ This file is public domain and comes with NO WARRANTY of any kind */  	/*		8   Pack filename as short as possibly */  	/*		16  Resolve symbolic links for filename */  	/*		32  Resolve filename to full path */ +	/*		64  Return NULL if too long path */ +#ifdef SCO +#define BUFF_LEN 4097 +#else  #ifdef MAXPATHLEN  #define BUFF_LEN MAXPATHLEN  #else  #define BUFF_LEN FN_LEN  #endif +#endif  my_string fn_format(my_string to, const char *name, const char *dsk,  		    const char *form, int flag) @@ -38,7 +43,8 @@ my_string fn_format(my_string to, const char *name, const char *dsk,    name+=(length=dirname_part(dev,(startpos=(my_string) name)));    if (length == 0 || flag & 1)    { -    (void) strmov(dev,dsk);			/* Use given directory */ +    (void) strmake(dev,dsk, sizeof(dev) - 2); +      /* Use given directory */      convert_dirname(dev);			/* Fix to this OS */    }    if (flag & 8) @@ -66,7 +72,10 @@ my_string fn_format(my_string to, const char *name, const char *dsk,    if (strlen(dev)+length+strlen(ext) >= FN_REFLEN || length >= FN_LEN )    {				/* To long path, return original */ -    uint tmp_length=strlength(startpos); +    uint tmp_length; +    if (flag & 64) +      return 0; +    tmp_length=strlength(startpos);      DBUG_PRINT("error",("dev: '%s'  ext: '%s'  length: %d",dev,ext,length));      (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));    } @@ -77,13 +86,14 @@ my_string fn_format(my_string to, const char *name, const char *dsk,        bmove(buff,(char*) name,length);		/* Save name for last copy */        name=buff;      } -    (void) strmov(strnmov(strmov(to,dev),name,length),ext); +    pos=strmake(strmov(to,dev),name,length);  #ifdef FN_UPPER_CASE      caseup_str(to);  #endif  #ifdef FN_LOWER_CASE      casedn_str(to);  #endif +    (void) strmov(pos,ext);			/* Don't convert extension */    }    /* Purify gives a lot of UMR errors when using realpath */  #if defined(HAVE_REALPATH) && !defined(HAVE_purify) @@ -93,7 +103,7 @@ my_string fn_format(my_string to, const char *name, const char *dsk,      if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))      {        if (realpath(to,buff)) -	strmov(to,buff); +	strmake(to,buff,FN_REFLEN-1);      }    }  #endif  | 
