Remove superfluous NULL checks. Add Andy's BN_FLG comment.
[openssl.git] / crypto / o_fopen.c
index a3a006574d70a15c4e0c76d8072643ccc8cbe6d9..1090a0687691989497cced4699f112c84f6cb6da 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
 #if !defined(OPENSSL_NO_STDIO)
 
 # include <stdio.h>
+# ifdef _WIN32
+#  include <windows.h>
+# endif
+# ifdef __DJGPP__
+#  include <unistd.h>
+# endif
 
 FILE *openssl_fopen(const char *filename, const char *mode)
 {
@@ -61,13 +67,14 @@ FILE *openssl_fopen(const char *filename, const char *mode)
     {
         char *newname = NULL;
 
-        if (!HAS_LFN_SUPPORT(filename)) {
+        if (pathconf(filename, _PC_NAME_MAX) <= 12) {  /* 8.3 file system? */
             char *iterator;
             char lastchar;
 
-            newname = OPENSSL_malloc(strlen(filename) + 1);
-            if (newname == NULL)
+            if ((newname = OPENSSL_malloc(strlen(filename) + 1)) == NULL) {
+                CRYPTOerr(CRYPTO_F_OPENSSL_FOPEN, ERR_R_MALLOC_FAILURE);
                 return NULL;
+            }
 
             for (iterator = newname, lastchar = '\0';
                 *filename; filename++, iterator++) {