aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog6
-rw-r--r--camel/camel-tcp-stream-ssl.c26
2 files changed, 25 insertions, 7 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 6823aeb365..3f03dd6ff6 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,11 @@
2003-03-21 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-tcp-stream-ssl.c (camel_certdb_nss_cert_get): continue
+ reading the cert file until we've read it all or get a non-EINTR
+ errno.
+
+2003-03-21 Jeffrey Stedfast <fejj@ximian.com>
+
* camel-sasl-gssapi.c: #include <com_err.h> instead of
#include <et/com_err.h>
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 614b3c552e..3a3f234544 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -630,9 +630,10 @@ camel_certdb_nss_cert_get(CamelCertDB *certdb, CERTCertificate *cert)
{
char *fingerprint, *path;
CamelCert *ccert;
- int fd;
- ssize_t len;
struct stat st;
+ size_t nread;
+ ssize_t n;
+ int fd;
fingerprint = cert_fingerprint (cert);
ccert = camel_certdb_get_cert (certdb, fingerprint);
@@ -656,11 +657,22 @@ camel_certdb_nss_cert_get(CamelCertDB *certdb, CERTCertificate *cert)
g_free(path);
ccert->rawcert = g_byte_array_new ();
- g_byte_array_set_size(ccert->rawcert, st.st_size);
- len = read(fd, ccert->rawcert->data, st.st_size);
- close(fd);
- if (len != st.st_size) {
- g_warning ("cert size read truncated %s: %d != %ld", path, len, st.st_size);
+ g_byte_array_set_size (ccert->rawcert, st.st_size);
+
+ nread = 0;
+ do {
+ do {
+ n = read (fd, ccert->rawcert->data + nread, st.st_size - nread);
+ } while (n == -1 && errno == EINTR);
+
+ if (n > 0)
+ nread += n;
+ } while (nread < st.st_size && n != -1);
+
+ close (fd);
+
+ if (nread != st.st_size) {
+ g_warning ("cert size read truncated %s: %d != %ld", path, nread, st.st_size);
g_byte_array_free(ccert->rawcert, TRUE);
ccert->rawcert = NULL;
g_free(fingerprint);