Unfortunately the DJGPP port is badly brocken in the master branch.
The provided patch shall fix the issues.

Both patches will fix/improve the following issues:
1) In Configure:
       For some reason -DTERMIO is set but DJGPP has never offered TERMIO making
       the build fail.  I have changed this to -DTERMIOS as is used to be.
2) In crypto/bio/bss_dgram.c:
       The superflous macro definitions of sock_write, sock_read and sock_puts
       enclosed by WATT32 have been removed.
3) In crypto/bio/bss_sock.c:
       Here the existing macro definitions for sock_write, sock_read and 
sock_puts
       are necessary and must be kept but they must be undefined before they can
       be defined.  This is because newer versions of Watt-32 also redefine 
them.
4) In crypto/conf/conf_def.c:
       If this port is used on MS-DOS or FreeDOS it becomes necessary to check 
if
       the underlying file system supports long file names (aka LFN) or not.  If
       it does not then file names with a leading dot like ".rnd" or ".ca_certs"
       are ilicit.  In function def_load_bio, the macros IS_RANDFILE and 
IS_CERT_DIR
       are used to check if the file system offers LFN support so that the file
       names with leading dots are licit and can be used.  If the tests fail
       then the new function dosify_filename is called and will substitute
       invalid characters in the file name by valid ones before using them.
       This check and the call of dosify_filename is enclosed by 
OPENSSL_SYS_MSDOS.
5) In e_os.h:
       In the DJGPP section the macros IS_RANDFILE and IS_CERT_DIR are defined.
       Also some auxiliar macros like HAS_LFN_SUPPORT and FILE_EXISTS are 
defined.
       Because neither MS-DOS nor FreeDOS provide 'egd' sockets, the 
DEVRANDOM_EGD
       macro is undefined.  This shall inhibit the compilation of code that does
       not work on MS-DOS/FreeDOS.
6) In INSTALL.DJGPP:
       Update URL of WATT-32 library.

I have checked the modified version of the master branch works on linux and
Cygwin.  They are no issues.  This is no surprise because the changes are
either enclosed by the __DJGPP__ or OPENSSL_SYS_MSDOS macros.
If more informaton is required please mail me.  I have attached the patch
as gzip'ed file too.


Regards,
Juan M. Guerrero






2016-01-04  Juan Manuel Guerrero  <juan.guerr...@gmx.de>

        * Configurations/10-main.conf:  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/conf/conf_def.c (def_load_bio) [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.

        * e_os.h [__DJGPP__]:  Undefine macro DEVRANDOM_EGD.  Neither MS-DOS
        nor FreeDOS provides 'egd' sockets.
        New macros IS_RANDFILE and IS_CERT_DIR are defined to identify the
        RANDFILE entry in openssl.cnf and the cert_dir entry in ssleay.conf.
        New macro RFILE that is defined either to ".rnd" or "_rnd" depending
        on if LFN support is available or not.

        * 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_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/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index ac07405..7d33a28 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -87,6 +87,9 @@ static int def_load_bio(CONF *conf, BIO *bp, long *eline);
  static int def_dump(const CONF *conf, BIO *bp);
  static int def_is_number(const CONF *conf, char c);
  static int def_to_int(const CONF *conf, char c);
+#ifdef OPENSSL_SYS_MSDOS
+static void dosify_filename(char *filename);
+#endif

  static CONF_METHOD default_method = {
      "OpenSSL default",
@@ -370,6 +373,10 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
              if (!str_copy(conf, psection, &(v->value), start))
                  goto err;

+#ifdef OPENSSL_SYS_MSDOS
+            if (IS_RANDFILE(v->name) || IS_CERT_DIR(v->name))
+                dosify_filename(v->value);
+#endif
              if (strcmp(psection, section) != 0) {
                  if ((tv = _CONF_get_section(conf, psection))
                      == NULL)
@@ -678,3 +685,24 @@ static int def_to_int(const CONF *conf, char c)
  {
      return c - '0';
  }
+
+#ifdef OPENSSL_SYS_MSDOS
+static void dosify_filename(char *filename)
+{
+  if (filename && *filename && !HAS_LFN_SUPPORT(filename))
+  {
+    char *slash;
+    int length;
+    for (length = 0; filename[length]; length++)
+      ;
+    for (slash = filename + length - 1; slash > filename && *slash != '/'; 
slash--)
+      ;
+
+    /* Leading dot not allowed on plain DOS.  */
+    if (slash[0] == '.')
+      slash[0] = '_';
+    else if (slash[1] == '.')
+      slash[1] = '_';
+  }
+}
+#endif
diff --git a/e_os.h b/e_os.h
index 5ab4c89..9a5f812 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,13 +195,33 @@ 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
+#   if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ 
>= 8))
+#    define __gnuc_extension__  __extension__
+#   else
+#    define __gnuc_extension__
+#   endif
+#   define FILE_EXISTS(name)      (access((name), R_OK) == 0)
+#   define HAS_LFN_SUPPORT(name)  (pathconf((name), _PC_NAME_MAX) > 12)
+#   define RFILE                                                               
         \
+    (__gnuc_extension__                                                        
         \
+      ({                                                                       
         \
+         char *rnd = HAS_LFN_SUPPORT(".rnd") && FILE_EXISTS(".rnd") ? ".rnd" : 
"_rnd";  \
+         rnd;                                                                  
         \
+      })                                                                       
         \
+    )
+#   undef DEVRANDOM_EGD  /*  Neither MS-DOS nor FreeDOS provide 'egd' sockets. 
 */
  #   undef DEVRANDOM
  #   define DEVRANDOM "/dev/urandom\x24"
+#   define IS_RANDFILE(n)  ((n)[0] == 'R' && (n)[1] == 'A' && (n)[2] == 'N' && 
(n)[3] == 'D' && \
+                            (n)[4] == 'F' && (n)[5] == 'I' && (n)[6] == 'L' && 
(n)[7] == 'E')
+#   define IS_CERT_DIR(n)  ((n)[0] == 'c' && (n)[1] == 'e' && (n)[2] == 'r' && 
(n)[3] == 't' && \
+                            (n)[4] == '_' && (n)[5] == 'd' && (n)[6] == 'i' && 
(n)[7] == 'r')
  #  endif                        /* __DJGPP__ */

  #  ifndef S_IFDIR
@@ -327,7 +348,9 @@ extern FILE *_imp___iob;
  #  endif
  #  define OPENSSL_CONF  "openssl.cnf"
  #  define NUL_DEV       "nul"
-#  define RFILE         ".rnd"
+#  ifndef RFILE
+#   define RFILE        ".rnd"
+#  endif
  #  ifdef OPENSSL_SYS_WINCE
  #   define DEFAULT_HOME  ""
  #  else

Attachment: djgpp-openssl-master.patch.gz
Description: GNU Zip compressed data

_______________________________________________
openssl-bugs-mod mailing list
openssl-bugs-...@openssl.org
https://mta.openssl.org/mailman/listinfo/openssl-bugs-mod
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev

Reply via email to