~ubuntu-branches/ubuntu/oneiric/inspircd/oneiric-security

« back to all changes in this revision

Viewing changes to src/modules/extra/m_ssl_gnutls.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2008-11-15 20:39:50 UTC
  • mfrom: (1.1.4 upstream) (3.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081115203950-uv1pf98x2vkon7se
Tags: 1.1.21+dfsg-1ubuntu1
* Merge from debian unstable, remaining changes: (LP: #298418)
  - debian/patches/04_include-limits-h.dpatch:
    + Explicitly include limits.h for gcc 4.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
        int dh_bits;
85
85
 
86
86
        int clientactive;
 
87
        bool cred_alloc;
87
88
 
88
89
 public:
89
90
 
96
97
                inbufsize = ServerInstance->Config->NetBufferSize;
97
98
 
98
99
                gnutls_global_init(); // This must be called once in the program
99
 
 
100
 
                if(gnutls_certificate_allocate_credentials(&x509_cred) != 0)
101
 
                        ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to allocate certificate credentials");
102
 
 
103
 
                // Guessing return meaning
104
 
                if(gnutls_dh_params_init(&dh_params) < 0)
105
 
                        ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to initialise DH parameters");
106
 
 
 
100
                
 
101
                cred_alloc = false;
107
102
                // Needs the flag as it ignores a plain /rehash
108
103
                OnRehash(NULL,"ssl");
109
104
 
207
202
                        keyfile = confdir + keyfile;
208
203
 
209
204
                int ret;
210
 
 
 
205
                
 
206
                if (cred_alloc)
 
207
                {
 
208
                        // Deallocate the old credentials
 
209
                        gnutls_dh_params_deinit(dh_params);
 
210
                        gnutls_certificate_free_credentials(x509_cred);
 
211
                }
 
212
                else
 
213
                        cred_alloc = true;
 
214
                
 
215
                if((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0)
 
216
                        ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to allocate certificate credentials: %s", gnutls_strerror(ret));
 
217
                
 
218
                if((ret = gnutls_dh_params_init(&dh_params)) < 0)
 
219
                        ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to initialise DH parameters: %s", gnutls_strerror(ret));
 
220
                
211
221
                if((ret =gnutls_certificate_set_x509_trust_file(x509_cred, cafile.c_str(), GNUTLS_X509_FMT_PEM)) < 0)
212
222
                        ServerInstance->Log(DEFAULT, "m_ssl_gnutls.so: Failed to set X.509 trust file '%s': %s", cafile.c_str(), gnutls_strerror(ret));
213
223
 
496
506
                                {
497
507
                                        memcpy(buffer, session->inbuf, count);
498
508
                                        // Move the stuff left in inbuf to the beginning of it
499
 
                                        memcpy(session->inbuf, session->inbuf + count, (length - count));
 
509
                                        memmove(session->inbuf, session->inbuf + count, (length - count));
500
510
                                        // Now we need to set session->inbufoffset to the amount of data still waiting to be handed to insp.
501
511
                                        session->inbufoffset = length - count;
502
512
                                        // Insp uses readresult as the count of how much data there is in buffer, so: