~ubuntu-branches/ubuntu/raring/curl/raring-updates

« back to all changes in this revision

Viewing changes to lib/ldap.c

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2011-11-13 21:07:32 UTC
  • mto: (3.6.1 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 55.
  • Revision ID: package-import@ubuntu.com-20111113210732-bk5n25x2tu7aplur
Tags: upstream-7.22.0
ImportĀ upstreamĀ versionĀ 7.22.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 * OpenLDAP library versions, USE_OPENLDAP shall not be defined.
36
36
 */
37
37
 
38
 
/* -- WIN32 approved -- */
39
 
#include <stdio.h>
40
 
#include <string.h>
41
 
#include <stdarg.h>
42
 
#include <stdlib.h>
43
 
#include <ctype.h>
44
 
#include <errno.h>
45
 
 
46
38
#ifdef CURL_LDAP_WIN            /* Use Windows LDAP implementation. */
47
39
# include <winldap.h>
48
40
# ifndef LDAP_VENDOR_NAME
113
105
  #define LDAP_TRACE(x)   do { \
114
106
                            _ldap_trace ("%u: ", __LINE__); \
115
107
                            _ldap_trace x; \
116
 
                          } while(0)
 
108
                          } WHILE_FALSE
117
109
 
118
110
  static void _ldap_trace (const char *fmt, ...);
119
111
#else
120
 
  #define LDAP_TRACE(x)   ((void)0)
 
112
  #define LDAP_TRACE(x)   Curl_nop_stmt
121
113
#endif
122
114
 
123
115
 
184
176
  struct SessionHandle *data=conn->data;
185
177
  int ldap_proto = LDAP_VERSION3;
186
178
  int ldap_ssl = 0;
187
 
  char *val_b64;
188
 
  size_t val_b64_sz;
189
 
  curl_off_t dlsize=0;
 
179
  char *val_b64 = NULL;
 
180
  size_t val_b64_sz = 0;
 
181
  curl_off_t dlsize = 0;
190
182
#ifdef LDAP_OPT_NETWORK_TIMEOUT
191
183
  struct timeval ldap_timeout = {10,0}; /* 10 sec connection/search timeout */
192
184
#endif
413
405
                      (char *)attribute +
414
406
                      (strlen((char *)attribute) - 7)) == 0)) {
415
407
            /* Binary attribute, encode to base64. */
416
 
            val_b64_sz = Curl_base64_encode(data,
417
 
                                            vals[i]->bv_val,
418
 
                                            vals[i]->bv_len,
419
 
                                            &val_b64);
 
408
            CURLcode error = Curl_base64_encode(data,
 
409
                                                vals[i]->bv_val,
 
410
                                                vals[i]->bv_len,
 
411
                                                &val_b64,
 
412
                                                &val_b64_sz);
 
413
            if(error) {
 
414
              ldap_value_free_len(vals);
 
415
              ldap_memfree(attribute);
 
416
              ldap_memfree(dn);
 
417
              if(ber)
 
418
                ber_free(ber, 0);
 
419
              status = error;
 
420
              goto quit;
 
421
            }
420
422
            if(val_b64_sz > 0) {
421
423
              Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
422
424
              free(val_b64);