ctld.c (0488e848d9ff76e640e0f8741c6ba124e71a7df8) | ctld.c (44a5953aa183aa8d3cc9514a1ef52a3e3bfe2856) |
---|---|
1/*- 2 * Copyright (c) 2012 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 547 unchanged lines hidden (view full) --- 556 portal->p_portal_group = pg; 557 TAILQ_INSERT_TAIL(&pg->pg_portals, portal, p_next); 558 return (portal); 559} 560 561static void 562portal_delete(struct portal *portal) 563{ | 1/*- 2 * Copyright (c) 2012 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 547 unchanged lines hidden (view full) --- 556 portal->p_portal_group = pg; 557 TAILQ_INSERT_TAIL(&pg->pg_portals, portal, p_next); 558 return (portal); 559} 560 561static void 562portal_delete(struct portal *portal) 563{ |
564 |
|
564 TAILQ_REMOVE(&portal->p_portal_group->pg_portals, portal, p_next); | 565 TAILQ_REMOVE(&portal->p_portal_group->pg_portals, portal, p_next); |
565 freeaddrinfo(portal->p_ai); | 566 if (portal->p_ai != NULL) 567 freeaddrinfo(portal->p_ai); |
566 free(portal->p_listen); 567 free(portal); 568} 569 570struct portal_group * 571portal_group_new(struct conf *conf, const char *name) 572{ 573 struct portal_group *pg; --- 54 unchanged lines hidden (view full) --- 628 629 portal = portal_new(pg); 630 portal->p_listen = checked_strdup(value); 631 portal->p_iser = iser; 632 633 arg = portal->p_listen; 634 if (arg[0] == '\0') { 635 log_warnx("empty listen address"); | 568 free(portal->p_listen); 569 free(portal); 570} 571 572struct portal_group * 573portal_group_new(struct conf *conf, const char *name) 574{ 575 struct portal_group *pg; --- 54 unchanged lines hidden (view full) --- 630 631 portal = portal_new(pg); 632 portal->p_listen = checked_strdup(value); 633 portal->p_iser = iser; 634 635 arg = portal->p_listen; 636 if (arg[0] == '\0') { 637 log_warnx("empty listen address"); |
636 free(portal->p_listen); 637 free(portal); | 638 portal_delete(portal); |
638 return (1); 639 } 640 if (arg[0] == '[') { 641 /* 642 * IPv6 address in square brackets, perhaps with port. 643 */ 644 arg++; 645 addr = strsep(&arg, "]"); 646 if (arg == NULL) { 647 log_warnx("invalid listen address %s", 648 portal->p_listen); | 639 return (1); 640 } 641 if (arg[0] == '[') { 642 /* 643 * IPv6 address in square brackets, perhaps with port. 644 */ 645 arg++; 646 addr = strsep(&arg, "]"); 647 if (arg == NULL) { 648 log_warnx("invalid listen address %s", 649 portal->p_listen); |
649 free(portal->p_listen); 650 free(portal); | 650 portal_delete(portal); |
651 return (1); 652 } 653 if (arg[0] == '\0') { 654 port = "3260"; 655 } else if (arg[0] == ':') { 656 port = arg + 1; 657 } else { 658 log_warnx("invalid listen address %s", 659 portal->p_listen); | 651 return (1); 652 } 653 if (arg[0] == '\0') { 654 port = "3260"; 655 } else if (arg[0] == ':') { 656 port = arg + 1; 657 } else { 658 log_warnx("invalid listen address %s", 659 portal->p_listen); |
660 free(portal->p_listen); 661 free(portal); | 660 portal_delete(portal); |
662 return (1); 663 } 664 } else { 665 /* 666 * Either IPv6 address without brackets - and without 667 * a port - or IPv4 address. Just count the colons. 668 */ 669 for (ch = arg; *ch != '\0'; ch++) { --- 16 unchanged lines hidden (view full) --- 686 hints.ai_family = PF_UNSPEC; 687 hints.ai_socktype = SOCK_STREAM; 688 hints.ai_flags = AI_PASSIVE; 689 690 error = getaddrinfo(addr, port, &hints, &portal->p_ai); 691 if (error != 0) { 692 log_warnx("getaddrinfo for %s failed: %s", 693 portal->p_listen, gai_strerror(error)); | 661 return (1); 662 } 663 } else { 664 /* 665 * Either IPv6 address without brackets - and without 666 * a port - or IPv4 address. Just count the colons. 667 */ 668 for (ch = arg; *ch != '\0'; ch++) { --- 16 unchanged lines hidden (view full) --- 685 hints.ai_family = PF_UNSPEC; 686 hints.ai_socktype = SOCK_STREAM; 687 hints.ai_flags = AI_PASSIVE; 688 689 error = getaddrinfo(addr, port, &hints, &portal->p_ai); 690 if (error != 0) { 691 log_warnx("getaddrinfo for %s failed: %s", 692 portal->p_listen, gai_strerror(error)); |
694 free(portal->p_listen); 695 free(portal); | 693 portal_delete(portal); |
696 return (1); 697 } 698 699 /* 700 * XXX: getaddrinfo(3) may return multiple addresses; we should turn 701 * those into multiple portals. 702 */ 703 --- 1279 unchanged lines hidden --- | 694 return (1); 695 } 696 697 /* 698 * XXX: getaddrinfo(3) may return multiple addresses; we should turn 699 * those into multiple portals. 700 */ 701 --- 1279 unchanged lines hidden --- |