Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

791 linhas
18 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/mem.h>
  63. #include "conf_def.h"
  64. #include "internal.h"
  65. static uint32_t conf_value_hash(const CONF_VALUE *v) {
  66. return (lh_strhash(v->section) << 2) ^ lh_strhash(v->name);
  67. }
  68. static int conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b) {
  69. int i;
  70. if (a->section != b->section) {
  71. i = strcmp(a->section, b->section);
  72. if (i) {
  73. return i;
  74. }
  75. }
  76. if (a->name != NULL && b->name != NULL) {
  77. return strcmp(a->name, b->name);
  78. } else if (a->name == b->name) {
  79. return 0;
  80. } else {
  81. return (a->name == NULL) ? -1 : 1;
  82. }
  83. }
  84. CONF *NCONF_new(void *method) {
  85. CONF *conf;
  86. if (method != NULL) {
  87. return NULL;
  88. }
  89. conf = OPENSSL_malloc(sizeof(CONF));
  90. if (conf == NULL) {
  91. return NULL;
  92. }
  93. conf->data = lh_CONF_VALUE_new(conf_value_hash, conf_value_cmp);
  94. if (conf->data == NULL) {
  95. OPENSSL_free(conf);
  96. return NULL;
  97. }
  98. return conf;
  99. }
  100. CONF_VALUE *CONF_VALUE_new(void) {
  101. CONF_VALUE *v = OPENSSL_malloc(sizeof(CONF_VALUE));
  102. if (!v) {
  103. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  104. return NULL;
  105. }
  106. memset(v, 0, sizeof(CONF_VALUE));
  107. return v;
  108. }
  109. static void value_free_contents(CONF_VALUE *value) {
  110. if (value->section) {
  111. OPENSSL_free(value->section);
  112. }
  113. if (value->name) {
  114. OPENSSL_free(value->name);
  115. if (value->value) {
  116. OPENSSL_free(value->value);
  117. }
  118. } else {
  119. if (value->value) {
  120. sk_CONF_VALUE_free((STACK_OF(CONF_VALUE)*)value->value);
  121. }
  122. }
  123. }
  124. static void value_free(CONF_VALUE *value) {
  125. value_free_contents(value);
  126. OPENSSL_free(value);
  127. }
  128. void NCONF_free(CONF *conf) {
  129. if (conf == NULL || conf->data == NULL) {
  130. return;
  131. }
  132. lh_CONF_VALUE_doall(conf->data, value_free);
  133. lh_CONF_VALUE_free(conf->data);
  134. OPENSSL_free(conf);
  135. }
  136. static CONF_VALUE *NCONF_new_section(const CONF *conf, const char *section) {
  137. STACK_OF(CONF_VALUE) *sk = NULL;
  138. int ok = 0;
  139. CONF_VALUE *v = NULL, *old_value;
  140. sk = sk_CONF_VALUE_new_null();
  141. v = CONF_VALUE_new();
  142. if (sk == NULL || v == NULL) {
  143. goto err;
  144. }
  145. v->section = OPENSSL_strdup(section);
  146. if (v->section == NULL) {
  147. goto err;
  148. }
  149. v->name = NULL;
  150. v->value = (char *)sk;
  151. if (!lh_CONF_VALUE_insert(conf->data, &old_value, v)) {
  152. goto err;
  153. }
  154. if (old_value) {
  155. value_free(old_value);
  156. }
  157. ok = 1;
  158. err:
  159. if (!ok) {
  160. if (sk != NULL) {
  161. sk_CONF_VALUE_free(sk);
  162. }
  163. if (v != NULL) {
  164. OPENSSL_free(v);
  165. }
  166. v = NULL;
  167. }
  168. return v;
  169. }
  170. static int str_copy(CONF *conf, char *section, char **pto, char *from) {
  171. int q, r, rr = 0, to = 0, len = 0;
  172. char *s, *e, *rp, *rrp, *np, *cp, v;
  173. const char *p;
  174. BUF_MEM *buf;
  175. buf = BUF_MEM_new();
  176. if (buf == NULL) {
  177. return 0;
  178. }
  179. len = strlen(from) + 1;
  180. if (!BUF_MEM_grow(buf, len)) {
  181. goto err;
  182. }
  183. for (;;) {
  184. if (IS_QUOTE(conf, *from)) {
  185. q = *from;
  186. from++;
  187. while (!IS_EOF(conf, *from) && (*from != q)) {
  188. if (IS_ESC(conf, *from)) {
  189. from++;
  190. if (IS_EOF(conf, *from)) {
  191. break;
  192. }
  193. }
  194. buf->data[to++] = *(from++);
  195. }
  196. if (*from == q) {
  197. from++;
  198. }
  199. } else if (IS_DQUOTE(conf, *from)) {
  200. q = *from;
  201. from++;
  202. while (!IS_EOF(conf, *from)) {
  203. if (*from == q) {
  204. if (*(from + 1) == q) {
  205. from++;
  206. } else {
  207. break;
  208. }
  209. }
  210. buf->data[to++] = *(from++);
  211. }
  212. if (*from == q) {
  213. from++;
  214. }
  215. } else if (IS_ESC(conf, *from)) {
  216. from++;
  217. v = *(from++);
  218. if (IS_EOF(conf, v)) {
  219. break;
  220. } else if (v == 'r') {
  221. v = '\r';
  222. } else if (v == 'n') {
  223. v = '\n';
  224. } else if (v == 'b') {
  225. v = '\b';
  226. } else if (v == 't') {
  227. v = '\t';
  228. }
  229. buf->data[to++] = v;
  230. } else if (IS_EOF(conf, *from)) {
  231. break;
  232. } else if (*from == '$') {
  233. /* try to expand it */
  234. rrp = NULL;
  235. s = &(from[1]);
  236. if (*s == '{') {
  237. q = '}';
  238. } else if (*s == '(') {
  239. q = ')';
  240. } else {
  241. q = 0;
  242. }
  243. if (q) {
  244. s++;
  245. }
  246. cp = section;
  247. e = np = s;
  248. while (IS_ALPHA_NUMERIC(conf, *e)) {
  249. e++;
  250. }
  251. if (e[0] == ':' && e[1] == ':') {
  252. cp = np;
  253. rrp = e;
  254. rr = *e;
  255. *rrp = '\0';
  256. e += 2;
  257. np = e;
  258. while (IS_ALPHA_NUMERIC(conf, *e)) {
  259. e++;
  260. }
  261. }
  262. r = *e;
  263. *e = '\0';
  264. rp = e;
  265. if (q) {
  266. if (r != q) {
  267. OPENSSL_PUT_ERROR(CONF, CONF_R_NO_CLOSE_BRACE);
  268. goto err;
  269. }
  270. e++;
  271. }
  272. /* So at this point we have
  273. * np which is the start of the name string which is
  274. * '\0' terminated.
  275. * cp which is the start of the section string which is
  276. * '\0' terminated.
  277. * e is the 'next point after'.
  278. * r and rr are the chars replaced by the '\0'
  279. * rp and rrp is where 'r' and 'rr' came from. */
  280. p = NCONF_get_string(conf, cp, np);
  281. if (rrp != NULL) {
  282. *rrp = rr;
  283. }
  284. *rp = r;
  285. if (p == NULL) {
  286. OPENSSL_PUT_ERROR(CONF, CONF_R_VARIABLE_HAS_NO_VALUE);
  287. goto err;
  288. }
  289. BUF_MEM_grow_clean(buf, (strlen(p) + buf->length - (e - from)));
  290. while (*p) {
  291. buf->data[to++] = *(p++);
  292. }
  293. /* Since we change the pointer 'from', we also have
  294. to change the perceived length of the string it
  295. points at. /RL */
  296. len -= e - from;
  297. from = e;
  298. /* In case there were no braces or parenthesis around
  299. the variable reference, we have to put back the
  300. character that was replaced with a '\0'. /RL */
  301. *rp = r;
  302. } else {
  303. buf->data[to++] = *(from++);
  304. }
  305. }
  306. buf->data[to] = '\0';
  307. if (*pto != NULL) {
  308. OPENSSL_free(*pto);
  309. }
  310. *pto = buf->data;
  311. OPENSSL_free(buf);
  312. return 1;
  313. err:
  314. if (buf != NULL) {
  315. BUF_MEM_free(buf);
  316. }
  317. return 0;
  318. }
  319. static CONF_VALUE *get_section(const CONF *conf, const char *section) {
  320. CONF_VALUE template;
  321. memset(&template, 0, sizeof(template));
  322. template.section = (char *) section;
  323. return lh_CONF_VALUE_retrieve(conf->data, &template);
  324. }
  325. STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, const char *section) {
  326. CONF_VALUE *section_value = get_section(conf, section);
  327. if (section_value == NULL) {
  328. return NULL;
  329. }
  330. return (STACK_OF(CONF_VALUE)*) section_value->value;
  331. }
  332. const char *NCONF_get_string(const CONF *conf, const char *section,
  333. const char *name) {
  334. CONF_VALUE template, *value;
  335. memset(&template, 0, sizeof(template));
  336. template.section = (char *) section;
  337. template.name = (char *) name;
  338. value = lh_CONF_VALUE_retrieve(conf->data, &template);
  339. if (value == NULL) {
  340. return NULL;
  341. }
  342. return value->value;
  343. }
  344. static int add_string(const CONF *conf, CONF_VALUE *section,
  345. CONF_VALUE *value) {
  346. STACK_OF(CONF_VALUE) *section_stack = (STACK_OF(CONF_VALUE)*) section->value;
  347. CONF_VALUE *old_value;
  348. value->section = OPENSSL_strdup(section->section);
  349. if (!sk_CONF_VALUE_push(section_stack, value)) {
  350. return 0;
  351. }
  352. if (!lh_CONF_VALUE_insert(conf->data, &old_value, value)) {
  353. return 0;
  354. }
  355. if (old_value != NULL) {
  356. (void)sk_CONF_VALUE_delete_ptr(section_stack, old_value);
  357. value_free(old_value);
  358. }
  359. return 1;
  360. }
  361. static char *eat_ws(CONF *conf, char *p) {
  362. while (IS_WS(conf, *p) && !IS_EOF(conf, *p)) {
  363. p++;
  364. }
  365. return p;
  366. }
  367. #define scan_esc(conf, p) (((IS_EOF((conf), (p)[1])) ? ((p) + 1) : ((p) + 2)))
  368. static char *eat_alpha_numeric(CONF *conf, char *p) {
  369. for (;;) {
  370. if (IS_ESC(conf, *p)) {
  371. p = scan_esc(conf, p);
  372. continue;
  373. }
  374. if (!IS_ALPHA_NUMERIC_PUNCT(conf, *p)) {
  375. return p;
  376. }
  377. p++;
  378. }
  379. }
  380. static char *scan_quote(CONF *conf, char *p) {
  381. int q = *p;
  382. p++;
  383. while (!IS_EOF(conf, *p) && *p != q) {
  384. if (IS_ESC(conf, *p)) {
  385. p++;
  386. if (IS_EOF(conf, *p)) {
  387. return p;
  388. }
  389. }
  390. p++;
  391. }
  392. if (*p == q) {
  393. p++;
  394. }
  395. return p;
  396. }
  397. static char *scan_dquote(CONF *conf, char *p) {
  398. int q = *p;
  399. p++;
  400. while (!(IS_EOF(conf, *p))) {
  401. if (*p == q) {
  402. if (*(p + 1) == q) {
  403. p++;
  404. } else {
  405. break;
  406. }
  407. }
  408. p++;
  409. }
  410. if (*p == q) {
  411. p++;
  412. }
  413. return p;
  414. }
  415. static void clear_comments(CONF *conf, char *p) {
  416. for (;;) {
  417. if (IS_FCOMMENT(conf, *p)) {
  418. *p = '\0';
  419. return;
  420. }
  421. if (!IS_WS(conf, *p)) {
  422. break;
  423. }
  424. p++;
  425. }
  426. for (;;) {
  427. if (IS_COMMENT(conf, *p)) {
  428. *p = '\0';
  429. return;
  430. }
  431. if (IS_DQUOTE(conf, *p)) {
  432. p = scan_dquote(conf, p);
  433. continue;
  434. }
  435. if (IS_QUOTE(conf, *p)) {
  436. p = scan_quote(conf, p);
  437. continue;
  438. }
  439. if (IS_ESC(conf, *p)) {
  440. p = scan_esc(conf, p);
  441. continue;
  442. }
  443. if (IS_EOF(conf, *p)) {
  444. return;
  445. } else {
  446. p++;
  447. }
  448. }
  449. }
  450. static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) {
  451. static const size_t CONFBUFSIZE = 512;
  452. int bufnum = 0, i, ii;
  453. BUF_MEM *buff = NULL;
  454. char *s, *p, *end;
  455. int again;
  456. long eline = 0;
  457. char btmp[DECIMAL_SIZE(eline) + 1];
  458. CONF_VALUE *v = NULL, *tv;
  459. CONF_VALUE *sv = NULL;
  460. char *section = NULL, *buf;
  461. char *start, *psection, *pname;
  462. if ((buff = BUF_MEM_new()) == NULL) {
  463. OPENSSL_PUT_ERROR(CONF, ERR_R_BUF_LIB);
  464. goto err;
  465. }
  466. section = OPENSSL_strdup("default");
  467. if (section == NULL) {
  468. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  469. goto err;
  470. }
  471. sv = NCONF_new_section(conf, section);
  472. if (sv == NULL) {
  473. OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  474. goto err;
  475. }
  476. bufnum = 0;
  477. again = 0;
  478. for (;;) {
  479. if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) {
  480. OPENSSL_PUT_ERROR(CONF, ERR_R_BUF_LIB);
  481. goto err;
  482. }
  483. p = &(buff->data[bufnum]);
  484. *p = '\0';
  485. BIO_gets(in, p, CONFBUFSIZE - 1);
  486. p[CONFBUFSIZE - 1] = '\0';
  487. ii = i = strlen(p);
  488. if (i == 0 && !again) {
  489. break;
  490. }
  491. again = 0;
  492. while (i > 0) {
  493. if ((p[i - 1] != '\r') && (p[i - 1] != '\n')) {
  494. break;
  495. } else {
  496. i--;
  497. }
  498. }
  499. /* we removed some trailing stuff so there is a new
  500. * line on the end. */
  501. if (ii && i == ii) {
  502. again = 1; /* long line */
  503. } else {
  504. p[i] = '\0';
  505. eline++; /* another input line */
  506. }
  507. /* we now have a line with trailing \r\n removed */
  508. /* i is the number of bytes */
  509. bufnum += i;
  510. v = NULL;
  511. /* check for line continuation */
  512. if (bufnum >= 1) {
  513. /* If we have bytes and the last char '\\' and
  514. * second last char is not '\\' */
  515. p = &(buff->data[bufnum - 1]);
  516. if (IS_ESC(conf, p[0]) && ((bufnum <= 1) || !IS_ESC(conf, p[-1]))) {
  517. bufnum--;
  518. again = 1;
  519. }
  520. }
  521. if (again) {
  522. continue;
  523. }
  524. bufnum = 0;
  525. buf = buff->data;
  526. clear_comments(conf, buf);
  527. s = eat_ws(conf, buf);
  528. if (IS_EOF(conf, *s)) {
  529. continue; /* blank line */
  530. }
  531. if (*s == '[') {
  532. char *ss;
  533. s++;
  534. start = eat_ws(conf, s);
  535. ss = start;
  536. again:
  537. end = eat_alpha_numeric(conf, ss);
  538. p = eat_ws(conf, end);
  539. if (*p != ']') {
  540. if (*p != '\0' && ss != p) {
  541. ss = p;
  542. goto again;
  543. }
  544. OPENSSL_PUT_ERROR(CONF, CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
  545. goto err;
  546. }
  547. *end = '\0';
  548. if (!str_copy(conf, NULL, &section, start)) {
  549. goto err;
  550. }
  551. if ((sv = get_section(conf, section)) == NULL) {
  552. sv = NCONF_new_section(conf, section);
  553. }
  554. if (sv == NULL) {
  555. OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  556. goto err;
  557. }
  558. continue;
  559. } else {
  560. pname = s;
  561. psection = NULL;
  562. end = eat_alpha_numeric(conf, s);
  563. if ((end[0] == ':') && (end[1] == ':')) {
  564. *end = '\0';
  565. end += 2;
  566. psection = pname;
  567. pname = end;
  568. end = eat_alpha_numeric(conf, end);
  569. }
  570. p = eat_ws(conf, end);
  571. if (*p != '=') {
  572. OPENSSL_PUT_ERROR(CONF, CONF_R_MISSING_EQUAL_SIGN);
  573. goto err;
  574. }
  575. *end = '\0';
  576. p++;
  577. start = eat_ws(conf, p);
  578. while (!IS_EOF(conf, *p)) {
  579. p++;
  580. }
  581. p--;
  582. while ((p != start) && (IS_WS(conf, *p))) {
  583. p--;
  584. }
  585. p++;
  586. *p = '\0';
  587. if (!(v = CONF_VALUE_new())) {
  588. goto err;
  589. }
  590. if (psection == NULL) {
  591. psection = section;
  592. }
  593. v->name = OPENSSL_strdup(pname);
  594. if (v->name == NULL) {
  595. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  596. goto err;
  597. }
  598. if (!str_copy(conf, psection, &(v->value), start)) {
  599. goto err;
  600. }
  601. if (strcmp(psection, section) != 0) {
  602. if ((tv = get_section(conf, psection)) == NULL) {
  603. tv = NCONF_new_section(conf, psection);
  604. }
  605. if (tv == NULL) {
  606. OPENSSL_PUT_ERROR(CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  607. goto err;
  608. }
  609. } else {
  610. tv = sv;
  611. }
  612. if (add_string(conf, tv, v) == 0) {
  613. OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE);
  614. goto err;
  615. }
  616. v = NULL;
  617. }
  618. }
  619. if (buff != NULL) {
  620. BUF_MEM_free(buff);
  621. }
  622. if (section != NULL) {
  623. OPENSSL_free(section);
  624. }
  625. return 1;
  626. err:
  627. if (buff != NULL) {
  628. BUF_MEM_free(buff);
  629. }
  630. if (section != NULL) {
  631. OPENSSL_free(section);
  632. }
  633. if (out_error_line != NULL) {
  634. *out_error_line = eline;
  635. }
  636. BIO_snprintf(btmp, sizeof btmp, "%ld", eline);
  637. ERR_add_error_data(2, "line ", btmp);
  638. if (v != NULL) {
  639. if (v->name != NULL) {
  640. OPENSSL_free(v->name);
  641. }
  642. if (v->value != NULL) {
  643. OPENSSL_free(v->value);
  644. }
  645. if (v != NULL) {
  646. OPENSSL_free(v);
  647. }
  648. }
  649. return 0;
  650. }
  651. int NCONF_load(CONF *conf, const char *filename, long *out_error_line) {
  652. BIO *in = BIO_new_file(filename, "rb");
  653. int ret;
  654. if (in == NULL) {
  655. OPENSSL_PUT_ERROR(CONF, ERR_R_SYS_LIB);
  656. return 0;
  657. }
  658. ret = def_load_bio(conf, in, out_error_line);
  659. BIO_free(in);
  660. return ret;
  661. }
  662. int NCONF_load_bio(CONF *conf, BIO *bio, long *out_error_line) {
  663. return def_load_bio(conf, bio, out_error_line);
  664. }
  665. int CONF_parse_list(const char *list, char sep, int remove_whitespace,
  666. int (*list_cb)(const char *elem, int len, void *usr),
  667. void *arg) {
  668. int ret;
  669. const char *lstart, *tmpend, *p;
  670. if (list == NULL) {
  671. OPENSSL_PUT_ERROR(CONF, CONF_R_LIST_CANNOT_BE_NULL);
  672. return 0;
  673. }
  674. lstart = list;
  675. for (;;) {
  676. if (remove_whitespace) {
  677. while (*lstart && isspace((unsigned char)*lstart)) {
  678. lstart++;
  679. }
  680. }
  681. p = strchr(lstart, sep);
  682. if (p == lstart || !*lstart) {
  683. ret = list_cb(NULL, 0, arg);
  684. } else {
  685. if (p) {
  686. tmpend = p - 1;
  687. } else {
  688. tmpend = lstart + strlen(lstart) - 1;
  689. }
  690. if (remove_whitespace) {
  691. while (isspace((unsigned char)*tmpend)) {
  692. tmpend--;
  693. }
  694. }
  695. ret = list_cb(lstart, tmpend - lstart + 1, arg);
  696. }
  697. if (ret <= 0) {
  698. return ret;
  699. }
  700. if (p == NULL) {
  701. return 1;
  702. }
  703. lstart = p + 1;
  704. }
  705. }
  706. int CONF_modules_load_file(CONF_MUST_BE_NULL *filename, const char *appname,
  707. unsigned long flags) {
  708. return 1;
  709. }
  710. void CONF_modules_free(void) {}
  711. void OPENSSL_config(CONF_MUST_BE_NULL *config_name) {}
  712. void OPENSSL_no_config(void) {}