Project

General

Profile

Enhancement #750 » 0008-sanitize-configuration-parsing.patch

Loïc Gomez, 2022-01-10 19:27

View differences:

src/bip.c
538 538
			list_free(t->pdata);
539 539
			break;
540 540
		case LEX_AUTOJOIN_ON_KICK:
541
			l->autojoin_on_kick = t->ndata;
541
			l->autojoin_on_kick = (t->ndata > 0 ? 1 : 0);
542 542
			break;
543 543
		case LEX_FOLLOW_NICK:
544
			l->follow_nick = t->ndata;
544
			l->follow_nick = (t->ndata > 0 ? 1 : 0);
545 545
			break;
546 546
		case LEX_IGN_FIRST_NICK:
547
			l->ignore_first_nick = t->ndata;
547
			l->ignore_first_nick = (t->ndata > 0 ? 1 : 0);
548 548
			break;
549 549
		case LEX_IGNORE_CAPAB:
550
			l->ignore_server_capab = t->ndata;
550
			l->ignore_server_capab = (t->ndata > 0 ? 1 : 0);
551 551
			break;
552 552
		case LEX_AWAY_NICK:
553 553
			MOVE_STRING(l->away_nick, t->pdata);
......
560 560
			t->pdata = NULL;
561 561
			break;
562 562
		case LEX_LOG:
563
			l->log->log_to_file = t->ndata;
563
			l->log->log_to_file = (t->ndata > 0 ? 1 : 0);
564 564
			break;
565 565
#ifdef HAVE_LIBSSL
566 566
		case LEX_SSL_CHECK_MODE:
......
711 711
		u->bip_use_notice = DEFAULT_BIP_USE_NOTICE;
712 712
	}
713 713

  
714
	u->backlog = hds->backlog;
715
	u->always_backlog = hds->always_backlog;
716
	u->bl_msg_only = hds->bl_msg_only;
717
	u->backlog_lines = hds->backlog_lines;
718
	u->backlog_timestamp = hds->backlog_timestamp;
719
	u->blreset_on_talk = hds->blreset_on_talk;
714
	u->backlog = (hds->backlog > 0 ? 1 : 0);
715
	u->always_backlog = (hds->always_backlog > 0 ? 1 : 0);
716
	u->bl_msg_only = (hds->bl_msg_only > 0 ? 1 : 0);
717
	u->backlog_lines = (hds->backlog_lines > 0 ? 1 : 0);
718
	u->backlog_timestamp = (hds->backlog_timestamp > 0 ? 1 : 0);
719
	u->blreset_on_talk = (hds->blreset_on_talk > 0 ? 1 : 0);
720 720

  
721 721
	while ((t = list_remove_first(data))) {
722 722
		switch (t->type) {
......
724 724
			MOVE_STRING(u->name, t->pdata);
725 725
			break;
726 726
		case LEX_ADMIN:
727
			u->admin = t->ndata;
727
			u->admin = (t->ndata > 0 ? 1 : 0);
728 728
			break;
729 729
		case LEX_PASSWORD:
730 730
			hash_binary(t->pdata, &u->password, &u->seed);
......
741 741
			MOVE_STRING(u->default_realname, t->pdata);
742 742
			break;
743 743
		case LEX_ALWAYS_BACKLOG:
744
			u->always_backlog = t->ndata;
744
			u->always_backlog = (t->ndata > 0 ? 1 : 0);
745 745
			break;
746 746
		case LEX_BACKLOG:
747
			u->backlog = t->ndata;
747
			u->backlog = (t->ndata > 0 ? 1 : 0);
748 748
			break;
749 749
		case LEX_BL_MSG_ONLY:
750
			u->bl_msg_only = t->ndata;
750
			u->bl_msg_only = (t->ndata > 0 ? 1 : 0);
751 751
			break;
752 752
		case LEX_BACKLOG_LINES:
753 753
			u->backlog_lines = t->ndata;
......
759 759
			u->backlog_timestamp = lex_backlog_timestamp(t->pdata);
760 760
			break;
761 761
		case LEX_BLRESET_ON_TALK:
762
			u->blreset_on_talk = t->ndata;
762
			u->blreset_on_talk = (t->ndata > 0 ? 1 : 0);
763 763
			break;
764 764
		case LEX_BLRESET_CONNECTION:
765
			u->blreset_connection = t->ndata;
765
			u->blreset_connection = (t->ndata > 0 ? 1 : 0);
766 766
			break;
767 767
		case LEX_BIP_USE_NOTICE:
768
			u->bip_use_notice = t->ndata;
768
			u->bip_use_notice = (t->ndata > 0 ? 1 : 0);
769 769
			break;
770 770
		case LEX_CONNECTION:
771 771
			list_add_last(&connection_list, t->pdata);
......
1007 1007
			MOVE_STRING(conf_ip, t->pdata);
1008 1008
			break;
1009 1009
		case LEX_PORT:
1010
			conf_port = t->ndata;
1010
			conf_port = (unsigned short)t->ndata;
1011 1011
			break;
1012 1012
		case LEX_RECONN_TIMER:
1013 1013
			conf_reconn_timer = t->ndata;
1014
- 
(7-7/24)