System.Data.SQLite
Check-in [d149920e68]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhance robustness of the new 'allowBaseDirectoryOnly' feature of the native library pre-loader.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | netStandard20
Files: files | file ages | folders
SHA1: d149920e68a28e3e46632eedca722caf75f246da
User & Date: mistachkin 2018-04-07 17:47:22
Context
2018-04-07
19:10
Use 'SQLITE_NET_CONFIGURATION_SUFFIX' in the .NET Core build scripts for POSIX. check-in: 6abb302e8b user: mistachkin tags: netStandard20
17:47
Enhance robustness of the new 'allowBaseDirectoryOnly' feature of the native library pre-loader. check-in: d149920e68 user: mistachkin tags: netStandard20
17:25
Fix shell script naming typo. check-in: ea81f2d9f7 user: mistachkin tags: netStandard20
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

   353    353         #endregion
   354    354   
   355    355         /////////////////////////////////////////////////////////////////////////
   356    356   
   357    357         #region Private Data
   358    358         /// <summary>
   359    359         /// This lock is used to protect the static <see cref="isMono" /> and
   360         -      /// <see cref="isDotNetCore" /> field.
          360  +      /// <see cref="isDotNetCore" /> fields.
   361    361         /// </summary>
   362    362         private static readonly object staticSyncRoot = new object();
   363    363   
   364    364         /////////////////////////////////////////////////////////////////////////
   365    365         /// <summary>
   366    366         /// This type is only present when running on Mono.
   367    367         /// </summary>
................................................................................
  3023   3023             string fileNameOnly = GetNativeLibraryFileNameOnly();
  3024   3024   
  3025   3025             if (fileNameOnly == null)
  3026   3026                 return false;
  3027   3027   
  3028   3028             //
  3029   3029             // NOTE: If the native SQLite library exists in the base directory
  3030         -          //       itself, stop now.
         3030  +          //       itself, possibly stop now.
  3031   3031             //
  3032   3032             string fileName = FixUpDllFileName(MaybeCombinePath(baseDirectory,
  3033   3033                 fileNameOnly));
  3034   3034   
  3035         -          if (!allowBaseDirectoryOnly && File.Exists(fileName))
  3036         -              return false;
         3035  +          if (File.Exists(fileName))
         3036  +          {
         3037  +              //
         3038  +              // NOTE: If the caller is allowing the base directory itself
         3039  +              //       to be used, also make sure a processor architecture
         3040  +              //       was not specified; if either condition is false just
         3041  +              //       stop now and return failure.
         3042  +              //
         3043  +              if (allowBaseDirectoryOnly &&
         3044  +                  String.IsNullOrEmpty(processorArchitecture))
         3045  +              {
         3046  +                  goto baseDirOnly;
         3047  +              }
         3048  +              else
         3049  +              {
         3050  +                  return false;
         3051  +              }
         3052  +          }
  3037   3053   
  3038   3054             //
  3039   3055             // NOTE: If the specified processor architecture is null, use the
  3040   3056             //       default.
  3041   3057             //
  3042   3058             if (processorArchitecture == null)
  3043   3059                 processorArchitecture = GetProcessorArchitecture();
................................................................................
  3082   3098   
  3083   3099                 //
  3084   3100                 // NOTE: If the file does not exist, skip trying to load it.
  3085   3101                 //
  3086   3102                 if (!File.Exists(fileName))
  3087   3103                     return false;
  3088   3104             }
         3105  +
         3106  +      baseDirOnly:
  3089   3107   
  3090   3108             try
  3091   3109             {
  3092   3110   #if !NET_COMPACT_20 && TRACE_PRELOAD
  3093   3111                 try
  3094   3112                 {
  3095   3113                     //