[openssl-dev] [openssl.org #4217] Fixing DJGPP port of openssl master branch.

Juan Manuel Guerrero juan.guerrero at gmx.de
Wed Jan 6 23:28:12 UTC 2016


Am 05.01.2016 04:05, schrieb Juan Manuel Guerrero via RT:
> Am 04.01.2016 21:22, schrieb Richard Levitte via RT:
>> Hi Juan, and thanks.
>>
>> I'm looking at your fix, and have a couple of questions:
[snip]

This is the last and final patch to fix the DJGPP port.  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.

Similar patches are also provided for the openssl 1.0.1 branch and the
openssl 1.0.2 branch 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.
	Include sys/un.h.
	Define WATT32_NO_OLDIES.

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









diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
index a82b95d..fad57a9 100644
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -1299,7 +1299,7 @@
      "DJGPP" => {
          inherit_from     => [ asm("x86_asm") ],
          cc               => "gcc",
-        cflags           => "-I/dev/env/WATT_ROOT/inc -DTERMIO -DL_ENDIAN -fomit-frame-pointer -O2 -Wall",
+        cflags           => "-I/dev/env/WATT_ROOT/inc -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O2 -Wall",
          sys_id           => "MSDOS",
          lflags           => "-L/dev/env/WATT_ROOT/lib -lwatt",
          bn_ops           => "BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}",
diff --git a/INSTALL.DJGPP b/INSTALL.DJGPP
index 1047ec9..23aed6a 100644
--- a/INSTALL.DJGPP
+++ b/INSTALL.DJGPP
@@ -18,7 +18,7 @@
   files to download, see the DJGPP "ZIP PICKER" page at
   "http://www.delorie.com/djgpp/zip-picker.html". You also need to have
   the WATT-32 networking package installed before you try to compile
- OpenSSL. This can be obtained from "http://www.bgnett.no/~giva/".
+ OpenSSL. This can be obtained from "http://www.watt-32.net/".
   The Makefile assumes that the WATT-32 code is in the directory
   specified by the environment variable WATT_ROOT. If you have watt-32
   in directory "watt32" under your main DJGPP directory, specify
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c
index 5e934ce..ca318cf 100644
--- a/crypto/bio/bss_dgram.c
+++ b/crypto/bio/bss_dgram.c
@@ -97,12 +97,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 c09a9a9..f34161c 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 file_write(BIO *h, const char *buf, int num);
  static int file_read(BIO *h, char *buf, int size);
  static int 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 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
  #else

  static int file_write(BIO *b, const char *in, int inl)
diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c
index 1673b32..5cef4f3 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 5ab4c89..6d52f13 100644
--- a/e_os.h
+++ b/e_os.h
@@ -141,6 +141,7 @@ extern "C" {
  #  define writesocket(s,b,n)      send((s),(b),(n),0)
  # elif defined(__DJGPP__)
  #  define WATT32
+#  define WATT32_NO_OLDIES
  #  define get_last_socket_error() errno
  #  define clear_socket_error()    errno=0
  #  define closesocket(s)          close_s(s)
@@ -194,11 +195,14 @@ extern "C" {
  #   include <unistd.h>
  #   include <sys/stat.h>
  #   include <sys/socket.h>
+#   include <sys/un.h>
  #   include <tcp.h>
  #   include <netdb.h>
  #   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__ */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: djgpp-openssl-SNAP-20160106.patch.gz
Type: application/x-gzip
Size: 2254 bytes
Desc: not available
URL: <http://mta.openssl.org/pipermail/openssl-dev/attachments/20160107/a58b3ebe/attachment.bin>


More information about the openssl-dev mailing list