[openssl-dev] [openssl.org #4208] : [PATCH] Some DJGPP specific fixes and improvements for OpenSSL_1_0_1-stable and OpenSSL_1_0_2-stable.

Juan Manuel Guerrero via RT rt at openssl.org
Thu Jan 7 00:17:35 UTC 2016


Am 29.12.2015 20:43, schrieb The default queue via RT:
> I have been using the DJGPP port of OpenSSL for a couple of years and I would
> like to propose some fixes and improvements.  No one of the proporsed changes
> have impact on any other port.  I supply two patches, one for today's OpenSSL_1_0_1-stable
> and one for today's openssl-OpenSSL_1_0_2-stable.  Patching the master branch
> is not so straight forward so it will follow later.
[snip]

This is the last and final patch to fix the DJGPP port of the OpenSSL_1_0_1-stable
branch.  It is similar to the one proposed for the master branch.  The only
difference compared with the initial patch is that it checks mow all file names
for LFN validity.  The dirname part and the basename part of the file name are
now checked for ilicit initial dots in the case that no LFN support is provided
by the file system.
I have attached the patch as gzip'ed file too.


Regards,
Juan M. Guerrero






2016-01-06  Juan Manuel Guerrero  <juan.guerrero at gmx.de>

	* Configure:  Replaced -DTERMIO by -DTERMIOS in CFLAGS.

	* crypto/bio/bss_dgram.c [WATT32]:  Remove obsolete redefinition of
	function names: sock_write, sock_read and sock_puts.

	* crypto/bio/bss_sock.c [WATT32]:  For Watt-32 2.2.11 sock_write,
	sock_read and sock_puts are redefined to their private names so their
	names must be undefined first before they can be redefined again.

	* crypto/bio/bss_file.c (file_fopen) [OPENSSL_SYS_MSDOS]:  Call
	dosify_filename to replace leading dot if file system does not support
	it.
	(dosify_filename):  Replace leading dot in passed file name if file
	system does not support LFN.  Replace all leading dots in the dirname
	part and the basname part of the file name.

	* e_os.h [__DJGPP__]:  Undefine macro DEVRANDOM_EGD.  Neither MS-DOS
	nor FreeDOS provide 'egd' sockets.
	New macro HAS_LFN_SUPPORT checks if underlying file system supports
	long file names or not.

	* util/mklink.pl:  Do not use symlinks for DJGPP.

	* INSTALL.DJGPP:  Update URL of WATT-32 library.









diff --git a/Configure b/Configure
index 84f627c..9ec48ed 100755
--- a/Configure
+++ b/Configure
@@ -574,7 +574,7 @@ my %table=(
  "netware-libc-bsdsock-gcc", "i586-netware-gcc:-nostdinc -I/ndk/libc/include -DNETWARE_BSDSOCK -DL_ENDIAN -DNETWARE_LIBC -DOPENSSL_SYSNAME_NETWARE -DTERMIO -O2 -Wall:::::BN_LLONG ${x86_gcc_opts}::",

  # DJGPP
-"DJGPP", "gcc:-I/dev/env/WATT_ROOT/inc -DTERMIO -DL_ENDIAN -fomit-frame-pointer -O2 -Wall:::MSDOS:-L/dev/env/WATT_ROOT/lib -lwatt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out:",
+"DJGPP", "gcc:-I/dev/env/WATT_ROOT/inc -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O2 -Wall:::MSDOS:-L/dev/env/WATT_ROOT/lib -lwatt:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_asm}:a.out:",

  # Ultrix from Bernhard Simon <simon at zid.tuwien.ac.at>
  "ultrix-cc","cc:-std1 -O -Olimit 2500 -DL_ENDIAN::(unknown):::::::",
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c
index d12b83a..1962712 100644
--- a/crypto/bio/bss_dgram.c
+++ b/crypto/bio/bss_dgram.c
@@ -90,12 +90,6 @@
           ((a)->s6_addr32[2] == htonl(0x0000ffff)))
  # endif

-# ifdef WATT32
-#  define sock_write SockWrite  /* Watt-32 uses same names */
-#  define sock_read  SockRead
-#  define sock_puts  SockPuts
-# endif
-
  static int dgram_write(BIO *h, const char *buf, int num);
  static int dgram_read(BIO *h, char *buf, int size);
  static int dgram_puts(BIO *h, const char *str);
diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c
index bfba93e..a9e5024 100644
--- a/crypto/bio/bss_file.c
+++ b/crypto/bio/bss_file.c
@@ -95,6 +95,10 @@

  # if !defined(OPENSSL_NO_STDIO)

+#ifdef OPENSSL_SYS_MSDOS
+# include <libc/unconst.h>
+static void dosify_filename(const char *filename);
+#endif
  static int MS_CALLBACK file_write(BIO *h, const char *buf, int num);
  static int MS_CALLBACK file_read(BIO *h, char *buf, int size);
  static int MS_CALLBACK file_puts(BIO *h, const char *str);
@@ -161,6 +165,9 @@ static FILE *file_fopen(const char *filename, const char *mode)
          file = fopen(filename, mode);
      }
  #  else
+#   ifdef OPENSSL_SYS_MSDOS
+    dosify_filename(filename);
+#   endif
      file = fopen(filename, mode);
  #  endif
      return (file);
@@ -467,6 +474,23 @@ static int MS_CALLBACK file_puts(BIO *bp, const char *str)
      return (ret);
  }

+#  ifdef OPENSSL_SYS_MSDOS
+static void dosify_filename(const char *filename)
+{
+    if (filename && *filename && !HAS_LFN_SUPPORT(filename)) {
+        char *namestart = unconst(filename, char *);
+
+        do {
+            if (namestart[0] == '/' && namestart[2] != '.' && namestart[2] != '/') {
+
+                /* Leading dot not allowed on plain DOS.  */
+                if (namestart[1] == '.')
+                    *++namestart = '_';
+            }
+        } while (*++namestart);
+    }
+}
+#  endif
  # endif                         /* OPENSSL_NO_STDIO */

  #endif                          /* HEADER_BSS_FILE_C */
diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c
index 6194d2c..7b3bf9c 100644
--- a/crypto/bio/bss_sock.c
+++ b/crypto/bio/bss_sock.c
@@ -66,7 +66,11 @@
  # include <openssl/bio.h>

  # ifdef WATT32
-#  define sock_write SockWrite  /* Watt-32 uses same names */
+/* Watt-32 uses same names */
+#  undef sock_write
+#  undef sock_read
+#  undef sock_puts
+#  define sock_write SockWrite
  #  define sock_read  SockRead
  #  define sock_puts  SockPuts
  # endif
diff --git a/e_os.h b/e_os.h
index 76c471e..7eb072f 100644
--- a/e_os.h
+++ b/e_os.h
@@ -242,6 +242,8 @@ extern "C" {
  #   define _setmode setmode
  #   define _O_TEXT O_TEXT
  #   define _O_BINARY O_BINARY
+#   define HAS_LFN_SUPPORT(name)  (pathconf((name), _PC_NAME_MAX) > 12)
+#   undef DEVRANDOM_EGD  /*  Neither MS-DOS nor FreeDOS provide 'egd' sockets.  */
  #   undef DEVRANDOM
  #   define DEVRANDOM "/dev/urandom\x24"
  #  endif                        /* __DJGPP__ */
diff --git a/util/mklink.pl b/util/mklink.pl
index 61db12c..194f246 100755
--- a/util/mklink.pl
+++ b/util/mklink.pl
@@ -51,7 +51,7 @@ my $to = join('/', @to_path);

  my $file;
  $symlink_exists=eval {symlink("",""); 1};
-if ($^O eq "msys") { $symlink_exists=0 };
+if ($^O eq "msys" || $^O eq 'dos') { $symlink_exists=0 };
  foreach $file (@files) {
      my $err = "";
      if ($symlink_exists) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: djgpp-openssl-1.0.1-stable-SNAP-20160105.patch.gz
Type: application/x-gzip
Size: 2113 bytes
Desc: not available
URL: <http://mta.openssl.org/pipermail/openssl-dev/attachments/20160107/7bd7e1c4/attachment.bin>


More information about the openssl-dev mailing list