rpms/nss_compat_ossl/F-8 nss_compat_ossl-layer.patch, NONE, 1.1 nss_compat_ossl.spec, 1.6, 1.7

Robert Crittenden (rcritten) fedora-extras-commits at redhat.com
Wed Jul 2 17:16:57 UTC 2008


Author: rcritten

Update of /cvs/extras/rpms/nss_compat_ossl/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15591

Modified Files:
	nss_compat_ossl.spec 
Added Files:
	nss_compat_ossl-layer.patch 
Log Message:
Fix BIO NSPR layer

Resolves: #453651


nss_compat_ossl-layer.patch:

--- NEW FILE nss_compat_ossl-layer.patch ---
diff -up ./src/nss_compat_ossl.h.bio-fix ./src/nss_compat_ossl.h
--- ./src/nss_compat_ossl.h.bio-fix	2007-09-20 10:21:53.000000000 -0700
+++ ./src/nss_compat_ossl.h	2008-06-26 00:32:30.000000000 -0700
@@ -207,6 +207,9 @@ struct bio_method_st
     int    (*destroy)(BIO *bio);
 };
 
+#define BIO_C_GET_FD 207
+#define BIO_C_GET_PEERNAME 209
+
 BIO *BIO_new(BIO_METHOD *);
 int SSL_set_bio(SSL *, BIO *, BIO *);
 
diff -up ./src/ssl.c.bio-fix ./src/ssl.c
--- ./src/ssl.c.bio-fix	2008-06-26 00:32:30.000000000 -0700
+++ ./src/ssl.c	2008-06-26 01:55:38.000000000 -0700
@@ -23,6 +23,7 @@
 #include <secmod.h>
 #include <termios.h> /* for echo on/off */
 #include <sys/stat.h>
+#include <errno.h>
 
 typedef struct {
     PRFileDesc         *pssl;
@@ -1312,6 +1313,18 @@ nspr_bio_write(PRFileDesc *fd, const voi
 }
 
 static PRInt32
+nspr_bio_send(PRFileDesc *fd, const void *buf, PRInt32 amount, 
+				PRIntn flags, PRIntervalTime timeout)
+{
+    BIO *bio = nspr_get_bio(fd);
+    if (!bio) {
+        return -1;
+    }
+
+    return bio->m->bwrite(bio, buf, amount);
+}
+
+static PRInt32
 nspr_bio_read(PRFileDesc *fd, void *buf, PRInt32 amount)
 {
     BIO *bio = nspr_get_bio(fd);
@@ -1323,6 +1336,267 @@ nspr_bio_read(PRFileDesc *fd, void *buf,
     return bio->m->bread(bio, buf, amount);
 }
 
+static PRInt32
+nspr_bio_recv(PRFileDesc *fd, void *buf, PRInt32 amount, 
+				PRIntn flags, PRIntervalTime timeout)
+{
+    BIO *bio = nspr_get_bio(fd);
+
+    if (!bio) {
+        return -1;
+    }
+
+    return bio->m->bread(bio, buf, amount);
+}
+
+void 
+npsr_map_error(int err)
+{
+    PRErrorCode prError;
+
+    switch (err ) {
+        case EACCES:
+            prError = PR_NO_ACCESS_RIGHTS_ERROR;
+            break;
+        case EADDRINUSE:
+            prError = PR_ADDRESS_IN_USE_ERROR;
+            break;
+        case EADDRNOTAVAIL:
+            prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;
+            break;
+        case EAFNOSUPPORT:
+            prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
+            break;
+        case EAGAIN:
+            prError = PR_WOULD_BLOCK_ERROR;
+            break;
+        /*
+         * On QNX and Neutrino, EALREADY is defined as EBUSY.
+         */
+#if EALREADY != EBUSY
+        case EALREADY:
+            prError = PR_ALREADY_INITIATED_ERROR;
+            break;
+#endif
+        case EBADF:
+            prError = PR_BAD_DESCRIPTOR_ERROR;
+            break;
+#ifdef EBADMSG
+        case EBADMSG:
+            prError = PR_IO_ERROR;
+            break;
+#endif
+        case EBUSY:
+            prError = PR_FILESYSTEM_MOUNTED_ERROR;
+            break;
+        case ECONNABORTED:
+            prError = PR_CONNECT_ABORTED_ERROR;
+            break;
+        case ECONNREFUSED:
+            prError = PR_CONNECT_REFUSED_ERROR;
+            break;
+        case ECONNRESET:
+            prError = PR_CONNECT_RESET_ERROR;
+            break;
+        case EDEADLK:
+            prError = PR_DEADLOCK_ERROR;
+            break;
+#ifdef EDIRCORRUPTED
+        case EDIRCORRUPTED:
+            prError = PR_DIRECTORY_CORRUPTED_ERROR;
+            break;
+#endif
+#ifdef EDQUOT
+        case EDQUOT:
+            prError = PR_NO_DEVICE_SPACE_ERROR;
+            break;
+#endif
+        case EEXIST:
+            prError = PR_FILE_EXISTS_ERROR;
+            break;
+        case EFAULT:
+            prError = PR_ACCESS_FAULT_ERROR;
+            break;
+        case EFBIG:
+            prError = PR_FILE_TOO_BIG_ERROR;
+            break;
+        case EHOSTUNREACH:
+            prError = PR_HOST_UNREACHABLE_ERROR;
+            break;
+        case EINPROGRESS:
+            prError = PR_IN_PROGRESS_ERROR;
+            break;
+        case EINTR:
+            prError = PR_PENDING_INTERRUPT_ERROR;
+            break;
+        case EINVAL:
+            prError = PR_INVALID_ARGUMENT_ERROR;
+            break;
+        case EIO:
+            prError = PR_IO_ERROR;
+            break;
+        case EISCONN:
+            prError = PR_IS_CONNECTED_ERROR;
+            break;
+        case EISDIR:
+            prError = PR_IS_DIRECTORY_ERROR;
+            break;
+        case ELOOP:
+            prError = PR_LOOP_ERROR;
+            break;
+        case EMFILE:
+            prError = PR_PROC_DESC_TABLE_FULL_ERROR;
+            break;
+        case EMLINK:
+            prError = PR_MAX_DIRECTORY_ENTRIES_ERROR;
+            break;
+        case EMSGSIZE:
+            prError = PR_INVALID_ARGUMENT_ERROR;
+            break;
+#ifdef EMULTIHOP
+        case EMULTIHOP:
+            prError = PR_REMOTE_FILE_ERROR;
+            break;
+#endif
+        case ENAMETOOLONG:
+            prError = PR_NAME_TOO_LONG_ERROR;
+            break;
+        case ENETUNREACH:
+            prError = PR_NETWORK_UNREACHABLE_ERROR;
+            break;
+        case ENFILE:
+            prError = PR_SYS_DESC_TABLE_FULL_ERROR;
+            break;
+        /*
+         * On SCO OpenServer 5, ENOBUFS is defined as ENOSR.
+         */
+#if defined(ENOBUFS) && (ENOBUFS != ENOSR)
+        case ENOBUFS:
+            prError = PR_INSUFFICIENT_RESOURCES_ERROR;
+            break;
+#endif
+        case ENODEV:
+            prError = PR_FILE_NOT_FOUND_ERROR;
+            break;
+        case ENOENT:
+            prError = PR_FILE_NOT_FOUND_ERROR;
+            break;
+        case ENOLCK:
+            prError = PR_FILE_IS_LOCKED_ERROR;
+            break;
+#ifdef ENOLINK 
+        case ENOLINK:
+            prError = PR_REMOTE_FILE_ERROR;
+            break;
+#endif
+        case ENOMEM:
+            prError = PR_OUT_OF_MEMORY_ERROR;
+            break;
+        case ENOPROTOOPT:
+            prError = PR_INVALID_ARGUMENT_ERROR;
+            break;
+        case ENOSPC:
+            prError = PR_NO_DEVICE_SPACE_ERROR;
+            break;
+#ifdef ENOSR
+        case ENOSR:
+            prError = PR_INSUFFICIENT_RESOURCES_ERROR;
+            break;
+#endif
+        case ENOTCONN:
+            prError = PR_NOT_CONNECTED_ERROR;
+            break;
+        case ENOTDIR:
+            prError = PR_NOT_DIRECTORY_ERROR;
+            break;
+        case ENOTSOCK:
+            prError = PR_NOT_SOCKET_ERROR;
+            break;
+        case ENXIO:
+            prError = PR_FILE_NOT_FOUND_ERROR;
+            break;
+        case EOPNOTSUPP:
+            prError = PR_NOT_TCP_SOCKET_ERROR;
+            break;
+#ifdef EOVERFLOW
+        case EOVERFLOW:
+            prError = PR_BUFFER_OVERFLOW_ERROR;
+            break;
+#endif
+        case EPERM:
+            prError = PR_NO_ACCESS_RIGHTS_ERROR;
+            break;
+        case EPIPE:
+            prError = PR_CONNECT_RESET_ERROR;
+            break;
+#ifdef EPROTO
+        case EPROTO:
+            prError = PR_IO_ERROR;
+            break;
+#endif
+        case EPROTONOSUPPORT:
+            prError = PR_PROTOCOL_NOT_SUPPORTED_ERROR;
+            break;
+        case EPROTOTYPE:
+            prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
+            break;
+        case ERANGE:
+            prError = PR_INVALID_METHOD_ERROR;
+            break;
+        case EROFS:
+            prError = PR_READ_ONLY_FILESYSTEM_ERROR;
+            break;
+        case ESPIPE:
+            prError = PR_INVALID_METHOD_ERROR;
+            break;
+        case ETIMEDOUT:
+            prError = PR_IO_TIMEOUT_ERROR;
+            break;
+#if EWOULDBLOCK != EAGAIN
+        case EWOULDBLOCK:
+            prError = PR_WOULD_BLOCK_ERROR;
+            break;
+#endif
+        case EXDEV:
+            prError = PR_NOT_SAME_DEVICE_ERROR;
+            break;
+        default:
+            prError = PR_UNKNOWN_ERROR;
+            break;
+    }
+    PR_SetError(prError, err);
+}
+
+static PRStatus
+nspr_bio_getpeername(PRFileDesc *fd, PRNetAddr *addr)
+{
+    BIO *bio = nspr_get_bio(fd);
+    int osfd;
+    int ret;
+    PRUint32 addrlen;
+
+    if (!bio) {
+        return -1;
+    }
+    ret = bio->m->ctrl(bio, BIO_C_GET_PEERNAME, sizeof(PRNetAddr), addr);
+    if (ret > 0) {
+	return PR_SUCCESS;
+    }
+	
+    ret = bio->m->ctrl(bio, BIO_C_GET_FD, sizeof(osfd), &osfd);
+    if (ret <= 0) {
+	PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF);
+	return PR_FAILURE;
+    }
+    ret = getpeername(osfd, (struct sockaddr *) addr, &addrlen);
+    if (ret < 0) {
+	npsr_map_error(errno);
+    }
+    
+    return ret == 0 ? PR_SUCCESS : PR_FAILURE;
+}
+
+
 static PRStatus
 nspr_bio_close(PRFileDesc *fd)
 {
@@ -1357,6 +1631,9 @@ ssl_init_bio()
     gBioMethods.write = nspr_bio_write;
     gBioMethods.read = nspr_bio_read;
     gBioMethods.close = nspr_bio_close;
+    gBioMethods.send = nspr_bio_send;
+    gBioMethods.recv = nspr_bio_recv;
+    gBioMethods.getpeername = nspr_bio_getpeername;
 }
 
 void SSL_load_error_strings(void)
@@ -2542,11 +2819,9 @@ int SSL_set_bio(SSL *s, BIO *bio, BIO *b
     }
 
     /* close the previous layer */
-    old = PR_PopIOLayer(s, gIdentity);
-    if (!old) {
-        old = PR_PopIOLayer(s, gBioIdentity);
-    }
+    old = PR_GetIdentitiesLayer(s, gBioIdentity);
     if (old) {
+	PR_PopIOLayer(s, gBioIdentity);
         old->dtor(old);
     }
 
@@ -2555,7 +2830,7 @@ int SSL_set_bio(SSL *s, BIO *bio, BIO *b
     if (new == NULL)
         goto error;
     nspr_set_bio(new , bio);
-    if (PR_PushIOLayer(s, PR_TOP_IO_LAYER, new) != PR_SUCCESS)
+    if (PR_PushIOLayer(s, PR_GetLayersIdentity(s->lower), new) != PR_SUCCESS)
         goto error;
 
     return 1;


Index: nss_compat_ossl.spec
===================================================================
RCS file: /cvs/extras/rpms/nss_compat_ossl/F-8/nss_compat_ossl.spec,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- nss_compat_ossl.spec	14 Oct 2007 02:04:13 -0000	1.6
+++ nss_compat_ossl.spec	2 Jul 2008 17:16:00 -0000	1.7
@@ -1,6 +1,6 @@
 Name:           nss_compat_ossl
 Version:        0.9.2
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        Source-level compatibility library for OpenSSL to NSS porting
 
 Group:          System Environment/Libraries
@@ -10,6 +10,7 @@
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Patch1:         nss_compat_ossl-symbol.patch
 Patch2:         nss_compat_ossl-link.patch
+Patch3:         nss_compat_ossl-layer.patch
 
 # Need > 3.11.7-7 so we have the NSS PKCS#11 flat-file reader available 
 BuildRequires:  nss-devel > 3.11.7-7
@@ -31,6 +32,7 @@
 %setup -q
 %patch1 -p1 -b .symbol
 %patch2 -p1 -b .link
+%patch3 -p1 -b .layer
 
 %build
 
@@ -68,6 +70,9 @@
 %postun -p /sbin/ldconfig
 
 %changelog
+* Wed Jun  2 2008 Rob Crittenden <rcritten at redhat.com> 0.9.2-4
+- Fix BIO NSPR layer (#453651)
+
 * Sat Oct 13 2007 Rob Crittenden <rcritten at redhat.com> 0.9.2-3
 - Bugzilla #330091, don't explicitly link with libsoftokn3.so
 




More information about the fedora-extras-commits mailing list