| OLD | NEW |
| 1 /* crypto/conf/conf.c */ | 1 /* crypto/conf/conf.c */ |
| 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
| 6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
| 7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
| 8 * | 8 * |
| 9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
| 10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 CONF_METHOD *NCONF_WIN32() | 123 CONF_METHOD *NCONF_WIN32() |
| 124 { | 124 { |
| 125 return &WIN32_method; | 125 return &WIN32_method; |
| 126 } | 126 } |
| 127 | 127 |
| 128 static CONF *def_create(CONF_METHOD *meth) | 128 static CONF *def_create(CONF_METHOD *meth) |
| 129 { | 129 { |
| 130 CONF *ret; | 130 CONF *ret; |
| 131 | 131 |
| 132 » ret = (CONF *)OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *)); | 132 » ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *)); |
| 133 if (ret) | 133 if (ret) |
| 134 if (meth->init(ret) == 0) | 134 if (meth->init(ret) == 0) |
| 135 { | 135 { |
| 136 OPENSSL_free(ret); | 136 OPENSSL_free(ret); |
| 137 ret = NULL; | 137 ret = NULL; |
| 138 } | 138 } |
| 139 return ret; | 139 return ret; |
| 140 } | 140 } |
| 141 | 141 |
| 142 static int def_init_default(CONF *conf) | 142 static int def_init_default(CONF *conf) |
| 143 { | 143 { |
| 144 if (conf == NULL) | 144 if (conf == NULL) |
| 145 return 0; | 145 return 0; |
| 146 | 146 |
| 147 conf->meth = &default_method; | 147 conf->meth = &default_method; |
| 148 » conf->meth_data = (void *)CONF_type_default; | 148 » conf->meth_data = CONF_type_default; |
| 149 conf->data = NULL; | 149 conf->data = NULL; |
| 150 | 150 |
| 151 return 1; | 151 return 1; |
| 152 } | 152 } |
| 153 | 153 |
| 154 static int def_init_WIN32(CONF *conf) | 154 static int def_init_WIN32(CONF *conf) |
| 155 { | 155 { |
| 156 if (conf == NULL) | 156 if (conf == NULL) |
| 157 return 0; | 157 return 0; |
| 158 | 158 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return ret; | 206 return ret; |
| 207 } | 207 } |
| 208 | 208 |
| 209 static int def_load_bio(CONF *conf, BIO *in, long *line) | 209 static int def_load_bio(CONF *conf, BIO *in, long *line) |
| 210 { | 210 { |
| 211 /* The macro BUFSIZE conflicts with a system macro in VxWorks */ | 211 /* The macro BUFSIZE conflicts with a system macro in VxWorks */ |
| 212 #define CONFBUFSIZE 512 | 212 #define CONFBUFSIZE 512 |
| 213 int bufnum=0,i,ii; | 213 int bufnum=0,i,ii; |
| 214 BUF_MEM *buff=NULL; | 214 BUF_MEM *buff=NULL; |
| 215 char *s,*p,*end; | 215 char *s,*p,*end; |
| 216 » int again,n; | 216 » int again; |
| 217 long eline=0; | 217 long eline=0; |
| 218 char btmp[DECIMAL_SIZE(eline)+1]; | 218 char btmp[DECIMAL_SIZE(eline)+1]; |
| 219 CONF_VALUE *v=NULL,*tv; | 219 CONF_VALUE *v=NULL,*tv; |
| 220 CONF_VALUE *sv=NULL; | 220 CONF_VALUE *sv=NULL; |
| 221 char *section=NULL,*buf; | 221 char *section=NULL,*buf; |
| 222 STACK_OF(CONF_VALUE) *section_sk=NULL,*ts; | |
| 223 char *start,*psection,*pname; | 222 char *start,*psection,*pname; |
| 224 void *h = (void *)(conf->data); | 223 void *h = (void *)(conf->data); |
| 225 | 224 |
| 226 if ((buff=BUF_MEM_new()) == NULL) | 225 if ((buff=BUF_MEM_new()) == NULL) |
| 227 { | 226 { |
| 228 CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_BUF_LIB); | 227 CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_BUF_LIB); |
| 229 goto err; | 228 goto err; |
| 230 } | 229 } |
| 231 | 230 |
| 232 section=(char *)OPENSSL_malloc(10); | 231 section=(char *)OPENSSL_malloc(10); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 243 goto err; | 242 goto err; |
| 244 } | 243 } |
| 245 | 244 |
| 246 sv=_CONF_new_section(conf,section); | 245 sv=_CONF_new_section(conf,section); |
| 247 if (sv == NULL) | 246 if (sv == NULL) |
| 248 { | 247 { |
| 249 CONFerr(CONF_F_DEF_LOAD_BIO, | 248 CONFerr(CONF_F_DEF_LOAD_BIO, |
| 250 CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | 249 CONF_R_UNABLE_TO_CREATE_NEW_SECTION); |
| 251 goto err; | 250 goto err; |
| 252 } | 251 } |
| 253 section_sk=(STACK_OF(CONF_VALUE) *)sv->value; | |
| 254 | 252 |
| 255 bufnum=0; | 253 bufnum=0; |
| 256 again=0; | 254 again=0; |
| 257 for (;;) | 255 for (;;) |
| 258 { | 256 { |
| 259 if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE)) | 257 if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE)) |
| 260 { | 258 { |
| 261 CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_BUF_LIB); | 259 CONFerr(CONF_F_DEF_LOAD_BIO,ERR_R_BUF_LIB); |
| 262 goto err; | 260 goto err; |
| 263 } | 261 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 { | 300 { |
| 303 bufnum--; | 301 bufnum--; |
| 304 again=1; | 302 again=1; |
| 305 } | 303 } |
| 306 } | 304 } |
| 307 if (again) continue; | 305 if (again) continue; |
| 308 bufnum=0; | 306 bufnum=0; |
| 309 buf=buff->data; | 307 buf=buff->data; |
| 310 | 308 |
| 311 clear_comments(conf, buf); | 309 clear_comments(conf, buf); |
| 312 n=strlen(buf); | |
| 313 s=eat_ws(conf, buf); | 310 s=eat_ws(conf, buf); |
| 314 if (IS_EOF(conf,*s)) continue; /* blank line */ | 311 if (IS_EOF(conf,*s)) continue; /* blank line */ |
| 315 if (*s == '[') | 312 if (*s == '[') |
| 316 { | 313 { |
| 317 char *ss; | 314 char *ss; |
| 318 | 315 |
| 319 s++; | 316 s++; |
| 320 start=eat_ws(conf, s); | 317 start=eat_ws(conf, s); |
| 321 ss=start; | 318 ss=start; |
| 322 again: | 319 again: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 336 *end='\0'; | 333 *end='\0'; |
| 337 if (!str_copy(conf,NULL,§ion,start)) goto err; | 334 if (!str_copy(conf,NULL,§ion,start)) goto err; |
| 338 if ((sv=_CONF_get_section(conf,section)) == NULL) | 335 if ((sv=_CONF_get_section(conf,section)) == NULL) |
| 339 sv=_CONF_new_section(conf,section); | 336 sv=_CONF_new_section(conf,section); |
| 340 if (sv == NULL) | 337 if (sv == NULL) |
| 341 { | 338 { |
| 342 CONFerr(CONF_F_DEF_LOAD_BIO, | 339 CONFerr(CONF_F_DEF_LOAD_BIO, |
| 343 CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | 340 CONF_R_UNABLE_TO_CREATE_NEW_SECTION); |
| 344 goto err; | 341 goto err; |
| 345 } | 342 } |
| 346 section_sk=(STACK_OF(CONF_VALUE) *)sv->value; | |
| 347 continue; | 343 continue; |
| 348 } | 344 } |
| 349 else | 345 else |
| 350 { | 346 { |
| 351 pname=s; | 347 pname=s; |
| 352 psection=NULL; | 348 psection=NULL; |
| 353 end=eat_alpha_numeric(conf, s); | 349 end=eat_alpha_numeric(conf, s); |
| 354 if ((end[0] == ':') && (end[1] == ':')) | 350 if ((end[0] == ':') && (end[1] == ':')) |
| 355 { | 351 { |
| 356 *end='\0'; | 352 *end='\0'; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 { | 395 { |
| 400 if ((tv=_CONF_get_section(conf,psection)) | 396 if ((tv=_CONF_get_section(conf,psection)) |
| 401 == NULL) | 397 == NULL) |
| 402 tv=_CONF_new_section(conf,psection); | 398 tv=_CONF_new_section(conf,psection); |
| 403 if (tv == NULL) | 399 if (tv == NULL) |
| 404 { | 400 { |
| 405 CONFerr(CONF_F_DEF_LOAD_BIO, | 401 CONFerr(CONF_F_DEF_LOAD_BIO, |
| 406 CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | 402 CONF_R_UNABLE_TO_CREATE_NEW_SECTION); |
| 407 goto err; | 403 goto err; |
| 408 } | 404 } |
| 409 ts=(STACK_OF(CONF_VALUE) *)tv->value; | |
| 410 } | 405 } |
| 411 else | 406 else |
| 412 { | |
| 413 tv=sv; | 407 tv=sv; |
| 414 ts=section_sk; | |
| 415 } | |
| 416 #if 1 | 408 #if 1 |
| 417 if (_CONF_add_string(conf, tv, v) == 0) | 409 if (_CONF_add_string(conf, tv, v) == 0) |
| 418 { | 410 { |
| 419 CONFerr(CONF_F_DEF_LOAD_BIO, | 411 CONFerr(CONF_F_DEF_LOAD_BIO, |
| 420 ERR_R_MALLOC_FAILURE); | 412 ERR_R_MALLOC_FAILURE); |
| 421 goto err; | 413 goto err; |
| 422 } | 414 } |
| 423 #else | 415 #else |
| 424 v->section=tv->section; | 416 v->section=tv->section; |
| 425 if (!sk_CONF_VALUE_push(ts,v)) | 417 if (!sk_CONF_VALUE_push(ts,v)) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 { | 450 { |
| 459 if (v->name != NULL) OPENSSL_free(v->name); | 451 if (v->name != NULL) OPENSSL_free(v->name); |
| 460 if (v->value != NULL) OPENSSL_free(v->value); | 452 if (v->value != NULL) OPENSSL_free(v->value); |
| 461 if (v != NULL) OPENSSL_free(v); | 453 if (v != NULL) OPENSSL_free(v); |
| 462 } | 454 } |
| 463 return(0); | 455 return(0); |
| 464 } | 456 } |
| 465 | 457 |
| 466 static void clear_comments(CONF *conf, char *p) | 458 static void clear_comments(CONF *conf, char *p) |
| 467 { | 459 { |
| 468 char *to; | |
| 469 | |
| 470 to=p; | |
| 471 for (;;) | 460 for (;;) |
| 472 { | 461 { |
| 473 if (IS_FCOMMENT(conf,*p)) | 462 if (IS_FCOMMENT(conf,*p)) |
| 474 { | 463 { |
| 475 *p='\0'; | 464 *p='\0'; |
| 476 return; | 465 return; |
| 477 } | 466 } |
| 478 if (!IS_WS(conf,*p)) | 467 if (!IS_WS(conf,*p)) |
| 479 { | 468 { |
| 480 break; | 469 break; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 { | 704 { |
| 716 break; | 705 break; |
| 717 } | 706 } |
| 718 } | 707 } |
| 719 p++; | 708 p++; |
| 720 } | 709 } |
| 721 if (*p == q) p++; | 710 if (*p == q) p++; |
| 722 return(p); | 711 return(p); |
| 723 } | 712 } |
| 724 | 713 |
| 725 static void dump_value(CONF_VALUE *a, BIO *out) | 714 static void dump_value_doall_arg(CONF_VALUE *a, BIO *out) |
| 726 { | 715 { |
| 727 if (a->name) | 716 if (a->name) |
| 728 BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value); | 717 BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value); |
| 729 else | 718 else |
| 730 BIO_printf(out, "[[%s]]\n", a->section); | 719 BIO_printf(out, "[[%s]]\n", a->section); |
| 731 } | 720 } |
| 732 | 721 |
| 733 static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *) | 722 static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE, BIO) |
| 734 | 723 |
| 735 static int def_dump(const CONF *conf, BIO *out) | 724 static int def_dump(const CONF *conf, BIO *out) |
| 736 { | 725 { |
| 737 » lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out); | 726 » lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), |
| 727 » » » » BIO, out); |
| 738 return 1; | 728 return 1; |
| 739 } | 729 } |
| 740 | 730 |
| 741 static int def_is_number(const CONF *conf, char c) | 731 static int def_is_number(const CONF *conf, char c) |
| 742 { | 732 { |
| 743 return IS_NUMBER(conf,c); | 733 return IS_NUMBER(conf,c); |
| 744 } | 734 } |
| 745 | 735 |
| 746 static int def_to_int(const CONF *conf, char c) | 736 static int def_to_int(const CONF *conf, char c) |
| 747 { | 737 { |
| 748 return c - '0'; | 738 return c - '0'; |
| 749 } | 739 } |
| 750 | 740 |
| OLD | NEW |