~ubuntu-branches/ubuntu/hardy/openswan/hardy-updates

« back to all changes in this revision

Viewing changes to lib/liblwres/lwconfig.c

  • Committer: Bazaar Package Importer
  • Author(s): Rene Mayrhofer
  • Date: 2005-01-27 16:10:11 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050127161011-idgybmyz3vwhpfiq
Tags: 2.3.0-2
Urgency HIGH due to security issue and problems with build-deps in sarge.
* Fix the security issue. Please see
  http://www.idefense.com/application/poi/display?id=190&
      type=vulnerabilities&flashstatus=false
  for more details. Thanks to Martin Schulze for informing me about
  this issue.
  Closes: #292458: Openswan XAUTH/PAM Buffer Overflow Vulnerability
* Added a Build-Dependency to lynx.
  Closes: #291143: openswan: FTBFS: Missing build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2000, 2001  Internet Software Consortium.
 
2
 * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
 
3
 * Copyright (C) 2000-2003  Internet Software Consortium.
3
4
 *
4
5
 * Permission to use, copy, modify, and distribute this software for any
5
6
 * purpose with or without fee is hereby granted, provided that the above
6
7
 * copyright notice and this permission notice appear in all copies.
7
8
 *
8
 
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
9
 
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10
 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11
 
 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12
 
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13
 
 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14
 
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15
 
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
9
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 
10
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 
11
 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 
12
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 
13
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 
14
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
15
 * PERFORMANCE OF THIS SOFTWARE.
16
16
 */
17
17
 
18
 
/* $Id: lwconfig.c,v 1.1.1.1 2002/09/30 19:51:06 mcr Exp $ */
 
18
/* $Id: lwconfig.c,v 1.2 2004/09/20 18:00:36 mcr Exp $ */
19
19
 
20
20
/***
21
21
 *** Module for parsing resolv.conf files.
156
156
        char *p = buffer;
157
157
 
158
158
        REQUIRE(buffer != NULL);
159
 
        REQUIRE(size > 0);
 
159
        REQUIRE(size > 0U);
160
160
 
161
161
        *p = '\0';
162
162
 
194
194
        char *p;
195
195
 
196
196
        REQUIRE(str != NULL);
197
 
        REQUIRE(strlen(str) > 0);
 
197
        REQUIRE(strlen(str) > 0U);
198
198
 
199
199
        p = CTXMALLOC(strlen(str) + 1);
200
200
        if (p != NULL)
220
220
        confdata->ndots = 1;
221
221
        confdata->no_tld_query = 0;
222
222
 
223
 
        for (i = 0 ; i < LWRES_CONFMAXNAMESERVERS ; i++)
 
223
        for (i = 0; i < LWRES_CONFMAXNAMESERVERS; i++)
224
224
                lwres_resetaddr(&confdata->nameservers[i]);
225
225
 
226
 
        for (i = 0 ; i < LWRES_CONFMAXSEARCH ; i++)
 
226
        for (i = 0; i < LWRES_CONFMAXSEARCH; i++)
227
227
                confdata->search[i] = NULL;
228
228
 
229
 
        for (i = 0 ; i < LWRES_CONFMAXSORTLIST ; i++) {
 
229
        for (i = 0; i < LWRES_CONFMAXSORTLIST; i++) {
230
230
                lwres_resetaddr(&confdata->sortlist[i].addr);
231
231
                lwres_resetaddr(&confdata->sortlist[i].mask);
232
232
        }
240
240
        REQUIRE(ctx != NULL);
241
241
        confdata = &ctx->confdata;
242
242
 
243
 
        for (i = 0 ; i < confdata->nsnext ; i++)
 
243
        for (i = 0; i < confdata->nsnext; i++)
244
244
                lwres_resetaddr(&confdata->nameservers[i]);
245
245
 
246
246
        if (confdata->domainname != NULL) {
249
249
                confdata->domainname = NULL;
250
250
        }
251
251
 
252
 
        for (i = 0 ; i < confdata->searchnxt ; i++) {
 
252
        for (i = 0; i < confdata->searchnxt; i++) {
253
253
                if (confdata->search[i] != NULL) {
254
254
                        CTXFREE(confdata->search[i],
255
255
                                strlen(confdata->search[i]) + 1);
257
257
                }
258
258
        }
259
259
 
260
 
        for (i = 0 ; i < LWRES_CONFMAXSORTLIST ; i++) {
 
260
        for (i = 0; i < LWRES_CONFMAXSORTLIST; i++) {
261
261
                lwres_resetaddr(&confdata->sortlist[i].addr);
262
262
                lwres_resetaddr(&confdata->sortlist[i].mask);
263
263
        }
284
284
                return (LWRES_R_SUCCESS);
285
285
 
286
286
        res = getword(fp, word, sizeof(word));
287
 
        if (strlen(word) == 0)
 
287
        if (strlen(word) == 0U)
288
288
                return (LWRES_R_FAILURE); /* Nothing on line. */
289
289
        else if (res == ' ' || res == '\t')
290
290
                res = eatwhite(fp);
312
312
                return (LWRES_R_SUCCESS);
313
313
 
314
314
        res = getword(fp, word, sizeof(word));
315
 
        if (strlen(word) == 0)
 
315
        if (strlen(word) == 0U)
316
316
                return (LWRES_R_FAILURE); /* Nothing on line. */
317
317
        else if (res == ' ' || res == '\t')
318
318
                res = eatwhite(fp);
337
337
        confdata = &ctx->confdata;
338
338
 
339
339
        res = getword(fp, word, sizeof(word));
340
 
        if (strlen(word) == 0)
 
340
        if (strlen(word) == 0U)
341
341
                return (LWRES_R_FAILURE); /* Nothing else on line. */
342
342
        else if (res == ' ' || res == '\t')
343
343
                res = eatwhite(fp);
352
352
        /*
353
353
         * Search and domain are mutually exclusive.
354
354
         */
355
 
        for (i = 0 ; i < LWRES_CONFMAXSEARCH ; i++) {
 
355
        for (i = 0; i < LWRES_CONFMAXSEARCH; i++) {
356
356
                if (confdata->search[i] != NULL) {
357
357
                        CTXFREE(confdata->search[i],
358
358
                                strlen(confdata->search[i])+1);
389
389
        /*
390
390
         * Remove any previous search definitions.
391
391
         */
392
 
        for (idx = 0 ; idx < LWRES_CONFMAXSEARCH ; idx++) {
 
392
        for (idx = 0; idx < LWRES_CONFMAXSEARCH; idx++) {
393
393
                if (confdata->search[idx] != NULL) {
394
394
                        CTXFREE(confdata->search[idx],
395
395
                                strlen(confdata->search[idx])+1);
399
399
        confdata->searchnxt = 0;
400
400
 
401
401
        delim = getword(fp, word, sizeof(word));
402
 
        if (strlen(word) == 0)
 
402
        if (strlen(word) == 0U)
403
403
                return (LWRES_R_FAILURE); /* Nothing else on line. */
404
404
 
405
405
        idx = 0;
406
 
        while (strlen(word) > 0) {
 
406
        while (strlen(word) > 0U) {
407
407
                if (confdata->searchnxt == LWRES_CONFMAXSEARCH)
408
408
                        goto ignore; /* Too many domains. */
409
409
 
460
460
        confdata = &ctx->confdata;
461
461
 
462
462
        delim = getword(fp, word, sizeof(word));
463
 
        if (strlen(word) == 0)
 
463
        if (strlen(word) == 0U)
464
464
                return (LWRES_R_FAILURE); /* Empty line after keyword. */
465
465
 
466
 
        while (strlen(word) > 0) {
 
466
        while (strlen(word) > 0U) {
467
467
                if (confdata->sortlistnxt == LWRES_CONFMAXSORTLIST)
468
468
                        return (LWRES_R_FAILURE); /* Too many values. */
469
469
 
516
516
        confdata = &ctx->confdata;
517
517
 
518
518
        delim = getword(fp, word, sizeof(word));
519
 
        if (strlen(word) == 0)
 
519
        if (strlen(word) == 0U)
520
520
                return (LWRES_R_FAILURE); /* Empty line after keyword. */
521
521
 
522
 
        while (strlen(word) > 0) {
 
522
        while (strlen(word) > 0U) {
523
523
                if (strcmp("debug", word) == 0) {
524
524
                        confdata->resdebug = 1;
525
525
                } else if (strcmp("no_tld_query", word) == 0) {
554
554
        confdata = &ctx->confdata;
555
555
 
556
556
        REQUIRE(filename != NULL);
557
 
        REQUIRE(strlen(filename) > 0);
 
557
        REQUIRE(strlen(filename) > 0U);
558
558
        REQUIRE(confdata != NULL);
559
559
 
560
560
        errno = 0;
569
569
                        break;
570
570
                }
571
571
 
572
 
                if (strlen(word) == 0)
 
572
                if (strlen(word) == 0U)
573
573
                        rval = LWRES_R_SUCCESS;
574
574
                else if (strcmp(word, "nameserver") == 0)
575
575
                        rval = lwres_conf_parsenameserver(ctx, fp);
581
581
                        rval = lwres_conf_parsesearch(ctx, fp);
582
582
                else if (strcmp(word, "sortlist") == 0)
583
583
                        rval = lwres_conf_parsesortlist(ctx, fp);
584
 
                else if (strcmp(word, "option") == 0)
 
584
                else if (strcmp(word, "options") == 0)
585
585
                        rval = lwres_conf_parseoption(ctx, fp);
586
586
                else {
587
587
                        /* unrecognised word. Ignore entire line */
604
604
lwres_conf_print(lwres_context_t *ctx, FILE *fp) {
605
605
        int i;
606
606
        int af;
607
 
        char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
 
607
        char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
608
608
        const char *p;
609
609
        lwres_conf_t *confdata;
610
610
        lwres_addr_t tmpaddr;
614
614
 
615
615
        REQUIRE(confdata->nsnext <= LWRES_CONFMAXNAMESERVERS);
616
616
 
617
 
        for (i = 0 ; i < confdata->nsnext ; i++) {
 
617
        for (i = 0; i < confdata->nsnext; i++) {
618
618
                af = lwresaddr2af(confdata->nameservers[i].family);
619
619
 
620
620
                p = lwres_net_ntop(af, confdata->nameservers[i].address,
625
625
                fprintf(fp, "nameserver %s\n", tmp);
626
626
        }
627
627
 
628
 
        for (i = 0 ; i < confdata->lwnext ; i++) {
 
628
        for (i = 0; i < confdata->lwnext; i++) {
629
629
                af = lwresaddr2af(confdata->lwservers[i].family);
630
630
 
631
631
                p = lwres_net_ntop(af, confdata->lwservers[i].address,
642
642
                REQUIRE(confdata->searchnxt <= LWRES_CONFMAXSEARCH);
643
643
 
644
644
                fprintf(fp, "search");
645
 
                for (i = 0 ; i < confdata->searchnxt ; i++)
 
645
                for (i = 0; i < confdata->searchnxt; i++)
646
646
                        fprintf(fp, " %s", confdata->search[i]);
647
647
                fputc('\n', fp);
648
648
        }
651
651
 
652
652
        if (confdata->sortlistnxt > 0) {
653
653
                fputs("sortlist", fp);
654
 
                for (i = 0 ; i < confdata->sortlistnxt ; i++) {
 
654
                for (i = 0; i < confdata->sortlistnxt; i++) {
655
655
                        af = lwresaddr2af(confdata->sortlist[i].addr.family);
656
656
 
657
657
                        p = lwres_net_ntop(af,