~sense/ubuntu/lucid/transmission/fix-497882

« back to all changes in this revision

Viewing changes to third-party/shttpd/io_ssl.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2008-11-28 15:33:48 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20081128153348-it70trfnxiroblmc
Tags: 1.40-0ubuntu1
* New upstream release (LP: #302672)
  - Tracker communication uses fewer resources
  - More accurate bandwidth limits
  - Reduce disk fragmentation by preallocating files (LP: #287726)
  - Stability, security and performance improvements to the RPC /
    Web UI server (closes LP: #290423)
  - Support compression when serving Web UI and RPC responses
  - Simplify the RPC whitelist
  - Fix bug that prevented handshakes with encrypted BitComet peers
  - Fix 1.3x bug that could re-download some data unnecessarily
    (LP: #295040)
  - Option to automatically update the blocklist weekly
  - Added off-hour bandwidth scheduling
  - Simplify file/priority selection in the details dialog
  - Fix a couple of crashes
  - New / updated translations
  - Don't inhibit hibernation by default (LP: #292929)
  - Use "close" animation when sending to notification area (LP: #130811)
  - Fix resize problems (LP: #269872)
  - Support "--version" option when launching from command line
    (LP: #292011)
  - Correctly parse announce URLs that have leading or trailing
    spaces (LP: #262411)
  - Display an error when "Open Torrent" fails (LP: #281463)
* Dropped 10_fix_crasher_from_upstream.dpatch: Fix is in this
  upstream release.
* debian/control: Don't just build-depend on libcurl-dev, which is
  a virtual package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2004-2005 Sergey Lyubka <valenok@gmail.com>
3
 
 * All rights reserved
4
 
 *
5
 
 * "THE BEER-WARE LICENSE" (Revision 42):
6
 
 * Sergey Lyubka wrote this file.  As long as you retain this notice you
7
 
 * can do whatever you want with this stuff. If we meet some day, and you think
8
 
 * this stuff is worth it, you can buy me a beer in return.
9
 
 */
10
 
 
11
 
#include "defs.h"
12
 
 
13
 
#if !defined(NO_SSL)
14
 
struct ssl_func ssl_sw[] = {
15
 
        {"SSL_free",                    {0}},
16
 
        {"SSL_accept",                  {0}},
17
 
        {"SSL_connect",                 {0}},
18
 
        {"SSL_read",                    {0}},
19
 
        {"SSL_write",                   {0}},
20
 
        {"SSL_get_error",               {0}},
21
 
        {"SSL_set_fd",                  {0}},
22
 
        {"SSL_new",                     {0}},
23
 
        {"SSL_CTX_new",                 {0}},
24
 
        {"SSLv23_server_method",        {0}},
25
 
        {"SSL_library_init",            {0}},
26
 
        {"SSL_CTX_use_PrivateKey_file", {0}},
27
 
        {"SSL_CTX_use_certificate_file",{0}},
28
 
        {NULL,                          {0}}
29
 
};
30
 
 
31
 
void
32
 
ssl_handshake(struct stream *stream)
33
 
{
34
 
        int     n;
35
 
 
36
 
        if ((n = SSL_accept(stream->chan.ssl.ssl)) == 1) {
37
 
                DBG(("handshake: SSL accepted"));
38
 
                stream->flags |= FLAG_SSL_ACCEPTED;
39
 
        } else {
40
 
                n = SSL_get_error(stream->chan.ssl.ssl, n);
41
 
                if (n != SSL_ERROR_WANT_READ && n != SSL_ERROR_WANT_WRITE)
42
 
                        stream->flags |= FLAG_CLOSED;
43
 
                DBG(("SSL_accept error %d", n));
44
 
        }
45
 
}
46
 
 
47
 
static int
48
 
read_ssl(struct stream *stream, void *buf, size_t len)
49
 
{
50
 
        int     nread = -1;
51
 
 
52
 
        assert(stream->chan.ssl.ssl != NULL);
53
 
 
54
 
        if (!(stream->flags & FLAG_SSL_ACCEPTED))
55
 
                ssl_handshake(stream);
56
 
 
57
 
        if (stream->flags & FLAG_SSL_ACCEPTED)
58
 
                nread = SSL_read(stream->chan.ssl.ssl, buf, len);
59
 
 
60
 
        return (nread);
61
 
}
62
 
 
63
 
static int
64
 
write_ssl(struct stream *stream, const void *buf, size_t len)
65
 
{
66
 
        assert(stream->chan.ssl.ssl != NULL);
67
 
        return (SSL_write(stream->chan.ssl.ssl, buf, len));
68
 
}
69
 
 
70
 
static void
71
 
close_ssl(struct stream *stream)
72
 
{
73
 
        assert(stream->chan.ssl.sock != -1);
74
 
        assert(stream->chan.ssl.ssl != NULL);
75
 
        (void) closesocket(stream->chan.ssl.sock);
76
 
        SSL_free(stream->chan.ssl.ssl);
77
 
}
78
 
 
79
 
const struct io_class   io_ssl =  {
80
 
        "ssl",
81
 
        read_ssl,
82
 
        write_ssl,
83
 
        close_ssl
84
 
};
85
 
#endif /* !NO_SSL */