diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-03-22 02:54:52 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-03-22 02:54:52 +0800 |
commit | 911fdb7885bba5043b823f99896e7d9b62b52b1f (patch) | |
tree | 37fb24ac3fc983a490e40187dd93f1d9169b4a85 /camel | |
parent | d66fdafdb7a8cca96aca191c717850a921be1984 (diff) | |
download | gsoc2013-evolution-911fdb7885bba5043b823f99896e7d9b62b52b1f.tar gsoc2013-evolution-911fdb7885bba5043b823f99896e7d9b62b52b1f.tar.gz gsoc2013-evolution-911fdb7885bba5043b823f99896e7d9b62b52b1f.tar.bz2 gsoc2013-evolution-911fdb7885bba5043b823f99896e7d9b62b52b1f.tar.lz gsoc2013-evolution-911fdb7885bba5043b823f99896e7d9b62b52b1f.tar.xz gsoc2013-evolution-911fdb7885bba5043b823f99896e7d9b62b52b1f.tar.zst gsoc2013-evolution-911fdb7885bba5043b823f99896e7d9b62b52b1f.zip |
continue reading the cert file until we've read it all or get a non-EINTR
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.
svn path=/trunk/; revision=20457
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 6 | ||||
-rw-r--r-- | camel/camel-tcp-stream-ssl.c | 26 |
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); |