Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

811 Zeilen
19 KiB

  1. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  2. * All rights reserved.
  3. *
  4. * This package is an SSL implementation written
  5. * by Eric Young (eay@cryptsoft.com).
  6. * The implementation was written so as to conform with Netscapes SSL.
  7. *
  8. * This library is free for commercial and non-commercial use as long as
  9. * the following conditions are aheared to. The following conditions
  10. * apply to all code found in this distribution, be it the RC4, RSA,
  11. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  12. * included with this distribution is covered by the same copyright terms
  13. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  14. *
  15. * Copyright remains Eric Young's, and as such any Copyright notices in
  16. * the code are not to be removed.
  17. * If this package is used in a product, Eric Young should be given attribution
  18. * as the author of the parts of the library used.
  19. * This can be in the form of a textual message at program startup or
  20. * in documentation (online or textual) provided with the package.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. All advertising materials mentioning features or use of this software
  31. * must display the following acknowledgement:
  32. * "This product includes cryptographic software written by
  33. * Eric Young (eay@cryptsoft.com)"
  34. * The word 'cryptographic' can be left out if the rouines from the library
  35. * being used are not cryptographic related :-).
  36. * 4. If you include any Windows specific code (or a derivative thereof) from
  37. * the apps directory (application code) you must include an acknowledgement:
  38. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * The licence and distribution terms for any publically available version or
  53. * derivative of this code cannot be changed. i.e. this code cannot simply be
  54. * copied and put under another distribution licence
  55. * [including the GNU Public Licence.] */
  56. #include <openssl/conf.h>
  57. #include <string.h>
  58. #include <ctype.h>
  59. #include <openssl/bio.h>
  60. #include <openssl/buf.h>
  61. #include <openssl/err.h>
  62. #include <openssl/lhash.h>
  63. #include <openssl/mem.h>
  64. #include "conf_def.h"
  65. #include "internal.h"
  66. #include "../internal.h"
  67. DEFINE_LHASH_OF(CONF_VALUE)
  68. struct conf_st {
  69. LHASH_OF(CONF_VALUE) *data;
  70. };
  71. // The maximum length we can grow a value to after variable expansion. 64k
  72. // should be more than enough for all reasonable uses.
  73. #define MAX_CONF_VALUE_LENGTH 65536
  74. static uint32_t conf_value_hash(const CONF_VALUE *v) {
  75. return (lh_strhash(v->section) << 2) ^ lh_strhash(v->name);
  76. }
  77. static int conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b) {
  78. int i;
  79. if (a->section != b->section) {
  80. i = strcmp(a->section, b->section);
  81. if (i) {
  82. return i;
  83. }
  84. }
  85. if (a->name != NULL && b->name != NULL) {
  86. return strcmp(a->name, b->name);
  87. } else if (a->name == b->name) {
  88. return 0;
  89. } else {
  90. return (a->name == NULL) ? -1 : 1;
  91. }
  92. }
  93. CONF *NCONF_new(void *method) {
  94. CONF *conf;
  95. if (method != NULL) {
  96. return NULL;
  97. }
  98. conf = OPENSSL_malloc(sizeof(CONF));
  99. if (conf == NULL) {
  100. return NULL;
  101. }
  102. conf->data = lh_CONF_VALUE_new(conf_value_hash, conf_value_cmp);
  103. if (conf->data == NULL) {
  104. OPENSSL_free(conf);
  105. return NULL;
  106. }
  107. return conf;
  108. }
  109. CONF_VALUE *CONF_VALUE_new(void) {
  110. CONF_VALUE *v = OPENSSL_malloc(sizeof(CONF_VALUE));
  111. if (!v) {
  112. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  113. return NULL;
  114. }
  115. OPENSSL_memset(v, 0, sizeof(CONF_VALUE));
  116. return v;
  117. }
  118. static void value_free_contents(CONF_VALUE *value) {
  119. if (value->section) {
  120. OPENSSL_free(value->section);
  121. }
  122. if (value->name) {
  123. OPENSSL_free(value->name);
  124. if (value->value) {
  125. OPENSSL_free(value->value);
  126. }
  127. } else {
  128. if (value->value) {
  129. sk_CONF_VALUE_free((STACK_OF(CONF_VALUE)*)value->value);
  130. }
  131. }
  132. }
  133. static void value_free(CONF_VALUE *value) {
  134. value_free_contents(value);
  135. OPENSSL_free(value);
  136. }
  137. void NCONF_free(CONF *conf) {
  138. if (conf == NULL || conf->data == NULL) {
  139. return;
  140. }
  141. lh_CONF_VALUE_doall(conf->data, value_free);
  142. lh_CONF_VALUE_free(conf->data);
  143. OPENSSL_free(conf);
  144. }
  145. static CONF_VALUE *NCONF_new_section(const CONF *conf, const char *section) {
  146. STACK_OF(CONF_VALUE) *sk = NULL;
  147. int ok = 0;
  148. CONF_VALUE *v = NULL, *old_value;
  149. sk = sk_CONF_VALUE_new_null();
  150. v = CONF_VALUE_new();
  151. if (sk == NULL || v == NULL) {
  152. goto err;
  153. }
  154. v->section = OPENSSL_strdup(section);
  155. if (v->section == NULL) {
  156. goto err;
  157. }
  158. v->name = NULL;
  159. v->value = (char *)sk;
  160. if (!lh_CONF_VALUE_insert(conf->data, &old_value, v)) {
  161. goto err;
  162. }
  163. if (old_value) {
  164. value_free(old_value);
  165. }
  166. ok = 1;
  167. err:
  168. if (!ok) {
  169. if (sk != NULL) {
  170. sk_CONF_VALUE_free(sk);
  171. }
  172. if (v != NULL) {
  173. OPENSSL_free(v);
  174. }
  175. v = NULL;
  176. }
  177. return v;
  178. }
  179. static int str_copy(CONF *conf, char *section, char **pto, char *from) {
  180. int q, r, rr = 0, to = 0, len = 0;
  181. char *s, *e, *rp, *rrp, *np, *cp, v;
  182. const char *p;
  183. BUF_MEM *buf;
  184. buf = BUF_MEM_new();
  185. if (buf == NULL) {
  186. return 0;
  187. }
  188. len = strlen(from) + 1;
  189. if (!BUF_MEM_grow(buf, len)) {
  190. goto err;
  191. }
  192. for (;;) {
  193. if (IS_QUOTE(conf, *from)) {
  194. q = *from;
  195. from++;
  196. while (!IS_EOF(conf, *from) && (*from != q)) {
  197. if (IS_ESC(conf, *from)) {
  198. from++;
  199. if (IS_EOF(conf, *from)) {
  200. break;
  201. }
  202. }
  203. buf->data[to++] = *(from++);
  204. }
  205. if (*from == q) {
  206. from++;
  207. }
  208. } else if (IS_DQUOTE(conf, *from)) {
  209. q = *from;
  210. from++;
  211. while (!IS_EOF(conf, *from)) {
  212. if (*from == q) {
  213. if (*(from + 1) == q) {
  214. from++;
  215. } else {
  216. break;
  217. }
  218. }
  219. buf->data[to++] = *(from++);
  220. }
  221. if (*from == q) {
  222. from++;
  223. }
  224. } else if (IS_ESC(conf, *from)) {
  225. from++;
  226. v = *(from++);
  227. if (IS_EOF(conf, v)) {
  228. break;
  229. } else if (v == 'r') {
  230. v = '\r';
  231. } else if (v == 'n') {
  232. v = '\n';
  233. } else if (v == 'b') {
  234. v = '\b';
  235. } else if (v == 't') {
  236. v = '\t';
  237. }
  238. buf->data[to++] = v;
  239. } else if (IS_EOF(conf, *from)) {
  240. break;
  241. } else if (*from == '$') {
  242. // try to expand it
  243. rrp = NULL;
  244. s = &(from[1]);
  245. if (*s == '{') {
  246. q = '}';
  247. } else if (*s == '(') {
  248. q = ')';
  249. } else {
  250. q = 0;
  251. }
  252. if (q) {
  253. s++;
  254. }
  255. cp = section;
  256. e = np = s;
  257. while (IS_ALPHA_NUMERIC(conf, *e)) {
  258. e++;
  259. }
  260. if (e[0] == ':' && e[1] == ':') {
  261. cp = np;
  262. rrp = e;
  263. rr = *e;
  264. *rrp = '\0';
  265. e += 2;
  266. np = e;
  267. while (IS_ALPHA_NUMERIC(conf, *e)) {
  268. e++;
  269. }
  270. }
  271. r = *e;
  272. *e = '\0';
  273. rp = e;
  274. if (q) {
  275. if (r != q) {
  276. OPENSSL_PUT_ERROR(CONF, CONF_R_NO_CLOSE_BRACE);
  277. goto err;
  278. }
  279. e++;
  280. }
  281. // So at this point we have
  282. // np which is the start of the name string which is
  283. // '\0' terminated.
  284. // cp which is the start of the section string which is
  285. // '\0' terminated.
  286. // e is the 'next point after'.
  287. // r and rr are the chars replaced by the '\0'
  288. // rp and rrp is where 'r' and 'rr' came from.
  289. p = NCONF_get_string(conf, cp, np);
  290. if (rrp != NULL) {
  291. *rrp = rr;
  292. }
  293. *rp = r;
  294. if (p == NULL) {
  295. OPENSSL_PUT_ERROR(CONF, CONF_R_VARIABLE_HAS_NO_VALUE);
  296. goto err;
  297. }
  298. size_t newsize = strlen(p) + buf->length - (e - from);
  299. if (newsize > MAX_CONF_VALUE_LENGTH) {
  300. OPENSSL_PUT_ERROR(CONF, CONF_R_VARIABLE_EXPANSION_TOO_LONG);
  301. goto err;
  302. }
  303. if (!BUF_MEM_grow_clean(buf, newsize)) {
  304. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  305. goto err;
  306. }
  307. while (*p) {
  308. buf->data[to++] = *(p++);
  309. }
  310. /* Since we change the pointer 'from', we also have
  311. to change the perceived length of the string it
  312. points at. /RL */
  313. len -= e - from;
  314. from = e;
  315. /* In case there were no braces or parenthesis around
  316. the variable reference, we have to put back the
  317. character that was replaced with a '\0'. /RL */
  318. *rp = r;
  319. } else {
  320. buf->data[to++] = *(from++);
  321. }
  322. }
  323. buf->data[to] = '\0';
  324. if (*pto != NULL) {
  325. OPENSSL_free(*pto);
  326. }
  327. *pto = buf->data;
  328. OPENSSL_free(buf);
  329. return 1;
  330. err:
  331. if (buf != NULL) {
  332. BUF_MEM_free(buf);
  333. }
  334. return 0;
  335. }
  336. static CONF_VALUE *get_section(const CONF *conf, const char *section) {
  337. CONF_VALUE template;
  338. OPENSSL_memset(&template, 0, sizeof(template));
  339. template.section = (char *) section;
  340. return lh_CONF_VALUE_retrieve(conf->data, &template);
  341. }
  342. STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, const char *section) {
  343. CONF_VALUE *section_value = get_section(conf, section);
  344. if (section_value == NULL) {
  345. return NULL;
  346. }
  347. return (STACK_OF(CONF_VALUE)*) section_value->value;
  348. }
  349. const char *NCONF_get_string(const CONF *conf, const char *section,
  350. const char *name) {
  351. CONF_VALUE template, *value;
  352. OPENSSL_memset(&template, 0, sizeof(template));
  353. template.section = (char *) section;
  354. template.name = (char *) name;
  355. value = lh_CONF_VALUE_retrieve(conf->data, &template);
  356. if (value == NULL) {
  357. return NULL;
  358. }
  359. return value->value;
  360. }
  361. static int add_string(const CONF *conf, CONF_VALUE *section,
  362. CONF_VALUE *value) {
  363. STACK_OF(CONF_VALUE) *section_stack = (STACK_OF(CONF_VALUE)*) section->value;
  364. CONF_VALUE *old_value;
  365. value->section = OPENSSL_strdup(section->section);
  366. if (!sk_CONF_VALUE_push(section_stack, value)) {
  367. return 0;
  368. }
  369. if (!lh_CONF_VALUE_insert(conf->data, &old_value, value)) {
  370. return 0;
  371. }
  372. if (old_value != NULL) {
  373. (void)sk_CONF_VALUE_delete_ptr(section_stack, old_value);
  374. value_free(old_value);
  375. }
  376. return 1;
  377. }
  378. static char *eat_ws(CONF *conf, char *p) {
  379. while (IS_WS(conf, *p) && !IS_EOF(conf, *p)) {
  380. p++;
  381. }
  382. return p;
  383. }
  384. #define scan_esc(conf, p) (((IS_EOF((conf), (p)[1])) ? ((p) + 1) : ((p) + 2)))
  385. static char *eat_alpha_numeric(CONF *conf, char *p) {
  386. for (;;) {
  387. if (IS_ESC(conf, *p)) {
  388. p = scan_esc(conf, p);
  389. continue;
  390. }
  391. if (!IS_ALPHA_NUMERIC_PUNCT(conf, *p)) {
  392. return p;
  393. }
  394. p++;
  395. }
  396. }
  397. static char *scan_quote(CONF *conf, char *p) {
  398. int q = *p;
  399. p++;
  400. while (!IS_EOF(conf, *p) && *p != q) {
  401. if (IS_ESC(conf, *p)) {
  402. p++;
  403. if (IS_EOF(conf, *p)) {
  404. return p;
  405. }
  406. }
  407. p++;
  408. }
  409. if (*p == q) {
  410. p++;
  411. }
  412. return p;
  413. }
  414. static char *scan_dquote(CONF *conf, char *p) {
  415. int q = *p;
  416. p++;
  417. while (!(IS_EOF(conf, *p))) {
  418. if (*p == q) {
  419. if (*(p + 1) == q) {
  420. p++;
  421. } else {
  422. break;
  423. }
  424. }
  425. p++;
  426. }
  427. if (*p == q) {
  428. p++;
  429. }
  430. return p;
  431. }
  432. static void clear_comments(CONF *conf, char *p) {
  433. for (;;) {
  434. if (IS_FCOMMENT(conf, *p)) {
  435. *p = '\0';
  436. return;
  437. }
  438. if (!IS_WS(conf, *p)) {
  439. break;
  440. }
  441. p++;
  442. }
  443. for (;;) {
  444. if (IS_COMMENT(conf, *p)) {
  445. *p = '\0';
  446. return;
  447. }
  448. if (IS_DQUOTE(conf, *p)) {
  449. p = scan_dquote(conf, p);
  450. continue;
  451. }
  452. if (IS_QUOTE(conf, *p)) {
  453. p = scan_quote(conf, p);
  454. continue;
  455. }
  456. if (IS_ESC(conf, *p)) {
  457. p = scan_esc(conf, p);
  458. continue;
  459. }
  460. if (IS_EOF(conf, *p)) {
  461. return;
  462. } else {
  463. p++;
  464. }
  465. }
  466. }
  467. static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) {
  468. static const size_t CONFBUFSIZE = 512;
  469. int bufnum = 0, i, ii;
  470. BUF_MEM *buff = NULL;
  471. char *s, *p, *end;
  472. int again;
  473. long eline = 0;
  474. char btmp[DECIMAL_SIZE(eline) + 1];
  475. CONF_VALUE *v = NULL, *tv;
  476. CONF_VALUE *sv = NULL;
  477. char *section = NULL, *buf;
  478. char *start, *psection, *pname;
  479. if ((buff = BUF_MEM_new()) == NULL) {
  480. OPENSSL_PUT_ERROR(CONF, ERR_R_BUF_LIB);
  481. goto err;
  482. }
  483. section = OPENSSL_strdup("default");
  484. if (section == NULL) {
  485. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  486. goto err;
  487. }
  488. sv = NCONF_new_section(conf, section);
  489. if (sv == NULL) {
  490. OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  491. goto err;
  492. }
  493. bufnum = 0;
  494. again = 0;
  495. for (;;) {
  496. if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) {
  497. OPENSSL_PUT_ERROR(CONF, ERR_R_BUF_LIB);
  498. goto err;
  499. }
  500. p = &(buff->data[bufnum]);
  501. *p = '\0';
  502. BIO_gets(in, p, CONFBUFSIZE - 1);
  503. p[CONFBUFSIZE - 1] = '\0';
  504. ii = i = strlen(p);
  505. if (i == 0 && !again) {
  506. break;
  507. }
  508. again = 0;
  509. while (i > 0) {
  510. if ((p[i - 1] != '\r') && (p[i - 1] != '\n')) {
  511. break;
  512. } else {
  513. i--;
  514. }
  515. }
  516. // we removed some trailing stuff so there is a new
  517. // line on the end.
  518. if (ii && i == ii) {
  519. again = 1; // long line
  520. } else {
  521. p[i] = '\0';
  522. eline++; // another input line
  523. }
  524. // we now have a line with trailing \r\n removed
  525. // i is the number of bytes
  526. bufnum += i;
  527. v = NULL;
  528. // check for line continuation
  529. if (bufnum >= 1) {
  530. // If we have bytes and the last char '\\' and
  531. // second last char is not '\\'
  532. p = &(buff->data[bufnum - 1]);
  533. if (IS_ESC(conf, p[0]) && ((bufnum <= 1) || !IS_ESC(conf, p[-1]))) {
  534. bufnum--;
  535. again = 1;
  536. }
  537. }
  538. if (again) {
  539. continue;
  540. }
  541. bufnum = 0;
  542. buf = buff->data;
  543. clear_comments(conf, buf);
  544. s = eat_ws(conf, buf);
  545. if (IS_EOF(conf, *s)) {
  546. continue; // blank line
  547. }
  548. if (*s == '[') {
  549. char *ss;
  550. s++;
  551. start = eat_ws(conf, s);
  552. ss = start;
  553. again:
  554. end = eat_alpha_numeric(conf, ss);
  555. p = eat_ws(conf, end);
  556. if (*p != ']') {
  557. if (*p != '\0' && ss != p) {
  558. ss = p;
  559. goto again;
  560. }
  561. OPENSSL_PUT_ERROR(CONF, CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
  562. goto err;
  563. }
  564. *end = '\0';
  565. if (!str_copy(conf, NULL, &section, start)) {
  566. goto err;
  567. }
  568. if ((sv = get_section(conf, section)) == NULL) {
  569. sv = NCONF_new_section(conf, section);
  570. }
  571. if (sv == NULL) {
  572. OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  573. goto err;
  574. }
  575. continue;
  576. } else {
  577. pname = s;
  578. psection = NULL;
  579. end = eat_alpha_numeric(conf, s);
  580. if ((end[0] == ':') && (end[1] == ':')) {
  581. *end = '\0';
  582. end += 2;
  583. psection = pname;
  584. pname = end;
  585. end = eat_alpha_numeric(conf, end);
  586. }
  587. p = eat_ws(conf, end);
  588. if (*p != '=') {
  589. OPENSSL_PUT_ERROR(CONF, CONF_R_MISSING_EQUAL_SIGN);
  590. goto err;
  591. }
  592. *end = '\0';
  593. p++;
  594. start = eat_ws(conf, p);
  595. while (!IS_EOF(conf, *p)) {
  596. p++;
  597. }
  598. p--;
  599. while ((p != start) && (IS_WS(conf, *p))) {
  600. p--;
  601. }
  602. p++;
  603. *p = '\0';
  604. if (!(v = CONF_VALUE_new())) {
  605. goto err;
  606. }
  607. if (psection == NULL) {
  608. psection = section;
  609. }
  610. v->name = OPENSSL_strdup(pname);
  611. if (v->name == NULL) {
  612. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  613. goto err;
  614. }
  615. if (!str_copy(conf, psection, &(v->value), start)) {
  616. goto err;
  617. }
  618. if (strcmp(psection, section) != 0) {
  619. if ((tv = get_section(conf, psection)) == NULL) {
  620. tv = NCONF_new_section(conf, psection);
  621. }
  622. if (tv == NULL) {
  623. OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  624. goto err;
  625. }
  626. } else {
  627. tv = sv;
  628. }
  629. if (add_string(conf, tv, v) == 0) {
  630. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  631. goto err;
  632. }
  633. v = NULL;
  634. }
  635. }
  636. if (buff != NULL) {
  637. BUF_MEM_free(buff);
  638. }
  639. if (section != NULL) {
  640. OPENSSL_free(section);
  641. }
  642. return 1;
  643. err:
  644. if (buff != NULL) {
  645. BUF_MEM_free(buff);
  646. }
  647. if (section != NULL) {
  648. OPENSSL_free(section);
  649. }
  650. if (out_error_line != NULL) {
  651. *out_error_line = eline;
  652. }
  653. BIO_snprintf(btmp, sizeof btmp, "%ld", eline);
  654. ERR_add_error_data(2, "line ", btmp);
  655. if (v != NULL) {
  656. if (v->name != NULL) {
  657. OPENSSL_free(v->name);
  658. }
  659. if (v->value != NULL) {
  660. OPENSSL_free(v->value);
  661. }
  662. if (v != NULL) {
  663. OPENSSL_free(v);
  664. }
  665. }
  666. return 0;
  667. }
  668. int NCONF_load(CONF *conf, const char *filename, long *out_error_line) {
  669. BIO *in = BIO_new_file(filename, "rb");
  670. int ret;
  671. if (in == NULL) {
  672. OPENSSL_PUT_ERROR(CONF, ERR_R_SYS_LIB);
  673. return 0;
  674. }
  675. ret = def_load_bio(conf, in, out_error_line);
  676. BIO_free(in);
  677. return ret;
  678. }
  679. int NCONF_load_bio(CONF *conf, BIO *bio, long *out_error_line) {
  680. return def_load_bio(conf, bio, out_error_line);
  681. }
  682. int CONF_parse_list(const char *list, char sep, int remove_whitespace,
  683. int (*list_cb)(const char *elem, int len, void *usr),
  684. void *arg) {
  685. int ret;
  686. const char *lstart, *tmpend, *p;
  687. if (list == NULL) {
  688. OPENSSL_PUT_ERROR(CONF, CONF_R_LIST_CANNOT_BE_NULL);
  689. return 0;
  690. }
  691. lstart = list;
  692. for (;;) {
  693. if (remove_whitespace) {
  694. while (*lstart && isspace((unsigned char)*lstart)) {
  695. lstart++;
  696. }
  697. }
  698. p = strchr(lstart, sep);
  699. if (p == lstart || !*lstart) {
  700. ret = list_cb(NULL, 0, arg);
  701. } else {
  702. if (p) {
  703. tmpend = p - 1;
  704. } else {
  705. tmpend = lstart + strlen(lstart) - 1;
  706. }
  707. if (remove_whitespace) {
  708. while (isspace((unsigned char)*tmpend)) {
  709. tmpend--;
  710. }
  711. }
  712. ret = list_cb(lstart, tmpend - lstart + 1, arg);
  713. }
  714. if (ret <= 0) {
  715. return ret;
  716. }
  717. if (p == NULL) {
  718. return 1;
  719. }
  720. lstart = p + 1;
  721. }
  722. }
  723. int CONF_modules_load_file(const char *filename, const char *appname,
  724. unsigned long flags) {
  725. return 1;
  726. }
  727. void CONF_modules_free(void) {}
  728. void OPENSSL_config(const char *config_name) {}
  729. void OPENSSL_no_config(void) {}