by_dir.c (59191) | by_dir.c (68651) |
---|---|
1/* crypto/x509/by_dir.c */ 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * --- 132 unchanged lines hidden (view full) --- 141 } 142 return(ret); 143 } 144 145static int new_dir(X509_LOOKUP *lu) 146 { 147 BY_DIR *a; 148 | 1/* crypto/x509/by_dir.c */ 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * --- 132 unchanged lines hidden (view full) --- 141 } 142 return(ret); 143 } 144 145static int new_dir(X509_LOOKUP *lu) 146 { 147 BY_DIR *a; 148 |
149 if ((a=(BY_DIR *)Malloc(sizeof(BY_DIR))) == NULL) | 149 if ((a=(BY_DIR *)OPENSSL_malloc(sizeof(BY_DIR))) == NULL) |
150 return(0); 151 if ((a->buffer=BUF_MEM_new()) == NULL) 152 { | 150 return(0); 151 if ((a->buffer=BUF_MEM_new()) == NULL) 152 { |
153 Free(a); | 153 OPENSSL_free(a); |
154 return(0); 155 } 156 a->num_dirs=0; 157 a->dirs=NULL; 158 a->dirs_type=NULL; 159 a->num_dirs_alloced=0; 160 lu->method_data=(char *)a; 161 return(1); 162 } 163 164static void free_dir(X509_LOOKUP *lu) 165 { 166 BY_DIR *a; 167 int i; 168 169 a=(BY_DIR *)lu->method_data; 170 for (i=0; i<a->num_dirs; i++) | 154 return(0); 155 } 156 a->num_dirs=0; 157 a->dirs=NULL; 158 a->dirs_type=NULL; 159 a->num_dirs_alloced=0; 160 lu->method_data=(char *)a; 161 return(1); 162 } 163 164static void free_dir(X509_LOOKUP *lu) 165 { 166 BY_DIR *a; 167 int i; 168 169 a=(BY_DIR *)lu->method_data; 170 for (i=0; i<a->num_dirs; i++) |
171 if (a->dirs[i] != NULL) Free(a->dirs[i]); 172 if (a->dirs != NULL) Free(a->dirs); 173 if (a->dirs_type != NULL) Free(a->dirs_type); | 171 if (a->dirs[i] != NULL) OPENSSL_free(a->dirs[i]); 172 if (a->dirs != NULL) OPENSSL_free(a->dirs); 173 if (a->dirs_type != NULL) OPENSSL_free(a->dirs_type); |
174 if (a->buffer != NULL) BUF_MEM_free(a->buffer); | 174 if (a->buffer != NULL) BUF_MEM_free(a->buffer); |
175 Free(a); | 175 OPENSSL_free(a); |
176 } 177 178static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) 179 { 180 int j,len; 181 int *ip; 182 const char *s,*ss,*p; 183 char **pp; --- 15 unchanged lines hidden (view full) --- 199 len=(int)(p-ss); 200 if (len == 0) continue; 201 for (j=0; j<ctx->num_dirs; j++) 202 if (strncmp(ctx->dirs[j],ss,(unsigned int)len) == 0) 203 continue; 204 if (ctx->num_dirs_alloced < (ctx->num_dirs+1)) 205 { 206 ctx->num_dirs_alloced+=10; | 176 } 177 178static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) 179 { 180 int j,len; 181 int *ip; 182 const char *s,*ss,*p; 183 char **pp; --- 15 unchanged lines hidden (view full) --- 199 len=(int)(p-ss); 200 if (len == 0) continue; 201 for (j=0; j<ctx->num_dirs; j++) 202 if (strncmp(ctx->dirs[j],ss,(unsigned int)len) == 0) 203 continue; 204 if (ctx->num_dirs_alloced < (ctx->num_dirs+1)) 205 { 206 ctx->num_dirs_alloced+=10; |
207 pp=(char **)Malloc(ctx->num_dirs_alloced* | 207 pp=(char **)OPENSSL_malloc(ctx->num_dirs_alloced* |
208 sizeof(char *)); | 208 sizeof(char *)); |
209 ip=(int *)Malloc(ctx->num_dirs_alloced* | 209 ip=(int *)OPENSSL_malloc(ctx->num_dirs_alloced* |
210 sizeof(int)); 211 if ((pp == NULL) || (ip == NULL)) 212 { 213 X509err(X509_F_ADD_CERT_DIR,ERR_R_MALLOC_FAILURE); 214 return(0); 215 } 216 memcpy(pp,ctx->dirs,(ctx->num_dirs_alloced-10)* 217 sizeof(char *)); 218 memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)* 219 sizeof(int)); 220 if (ctx->dirs != NULL) | 210 sizeof(int)); 211 if ((pp == NULL) || (ip == NULL)) 212 { 213 X509err(X509_F_ADD_CERT_DIR,ERR_R_MALLOC_FAILURE); 214 return(0); 215 } 216 memcpy(pp,ctx->dirs,(ctx->num_dirs_alloced-10)* 217 sizeof(char *)); 218 memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)* 219 sizeof(int)); 220 if (ctx->dirs != NULL) |
221 Free(ctx->dirs); | 221 OPENSSL_free(ctx->dirs); |
222 if (ctx->dirs_type != NULL) | 222 if (ctx->dirs_type != NULL) |
223 Free(ctx->dirs_type); | 223 OPENSSL_free(ctx->dirs_type); |
224 ctx->dirs=pp; 225 ctx->dirs_type=ip; 226 } 227 ctx->dirs_type[ctx->num_dirs]=type; | 224 ctx->dirs=pp; 225 ctx->dirs_type=ip; 226 } 227 ctx->dirs_type[ctx->num_dirs]=type; |
228 ctx->dirs[ctx->num_dirs]=(char *)Malloc((unsigned int)len+1); | 228 ctx->dirs[ctx->num_dirs]=(char *)OPENSSL_malloc((unsigned int)len+1); |
229 if (ctx->dirs[ctx->num_dirs] == NULL) return(0); 230 strncpy(ctx->dirs[ctx->num_dirs],ss,(unsigned int)len); 231 ctx->dirs[ctx->num_dirs][len]='\0'; 232 ctx->num_dirs++; 233 } 234 if (*p == '\0') break; 235 p++; 236 } --- 84 unchanged lines hidden (view full) --- 321 break; 322 } 323 /* else case will caught higher up */ 324 } 325 326 /* we have added it to the cache so now pull 327 * it out again */ 328 CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE); | 229 if (ctx->dirs[ctx->num_dirs] == NULL) return(0); 230 strncpy(ctx->dirs[ctx->num_dirs],ss,(unsigned int)len); 231 ctx->dirs[ctx->num_dirs][len]='\0'; 232 ctx->num_dirs++; 233 } 234 if (*p == '\0') break; 235 p++; 236 } --- 84 unchanged lines hidden (view full) --- 321 break; 322 } 323 /* else case will caught higher up */ 324 } 325 326 /* we have added it to the cache so now pull 327 * it out again */ 328 CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE); |
329 tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs,&stmp); | 329 j = sk_X509_OBJECT_find(xl->store_ctx->objs,&stmp); 330 if(j != -1) tmp=sk_X509_OBJECT_value(xl->store_ctx->objs,i); 331 else tmp = NULL; |
330 CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE); 331 332 if (tmp != NULL) 333 { 334 ok=1; 335 ret->type=tmp->type; 336 memcpy(&ret->data,&tmp->data,sizeof(ret->data)); 337 /* If we were going to up the reference count, --- 12 unchanged lines hidden --- | 332 CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE); 333 334 if (tmp != NULL) 335 { 336 ok=1; 337 ret->type=tmp->type; 338 memcpy(&ret->data,&tmp->data,sizeof(ret->data)); 339 /* If we were going to up the reference count, --- 12 unchanged lines hidden --- |