View | Details | Raw Unified | Return to bug 3379
Collapse All | Expand All

(-)openssh-8.8p1/readconf.c (-2 / +19 lines)
Lines 1746-1760 Link Here
1746
		break;
1746
		break;
1747
1747
1748
	case oSetEnv:
1748
	case oSetEnv:
1749
		value = options->num_setenv;
1750
		while ((arg = argv_next(&ac, &av)) != NULL) {
1749
		while ((arg = argv_next(&ac, &av)) != NULL) {
1751
			if (strchr(arg, '=') == NULL) {
1750
			if (strchr(arg, '=') == NULL) {
1752
				error("%s line %d: Invalid SetEnv.",
1751
				error("%s line %d: Invalid SetEnv.",
1753
				    filename, linenum);
1752
				    filename, linenum);
1754
				goto out;
1753
				goto out;
1755
			}
1754
			}
1756
			if (!*activep || value != 0)
1755
			if (!*activep)
1757
				continue;
1756
				continue;
1757
1758
			/* Update existing setenv var */
1759
			size_t envlen = strchr(arg, '=') - arg;
1760
			for (int i = 0; i < options->num_setenv; i++) {
1761
				if (strncmp(options->setenv[i], arg, envlen) == 0 ){
1762
					debug("%.200s line %d: Updating SetEnv "
1763
					    "from %s to %s "
1764
					    , filename, linenum,
1765
					    options->setenv[i], arg);
1766
					free(options->setenv[i]);
1767
					options->setenv[i] = xstrdup(arg);
1768
					goto no_new_env;
1769
				}
1770
			}
1771
1758
			/* Adding a setenv var */
1772
			/* Adding a setenv var */
1759
			if (options->num_setenv >= INT_MAX) {
1773
			if (options->num_setenv >= INT_MAX) {
1760
				error("%s line %d: too many SetEnv.",
1774
				error("%s line %d: too many SetEnv.",
Lines 1765-1770 Link Here
1765
			    options->setenv, options->num_setenv,
1779
			    options->setenv, options->num_setenv,
1766
			    options->num_setenv + 1, sizeof(*options->setenv));
1780
			    options->num_setenv + 1, sizeof(*options->setenv));
1767
			options->setenv[options->num_setenv++] = xstrdup(arg);
1781
			options->setenv[options->num_setenv++] = xstrdup(arg);
1782
1783
		 no_new_env:
1784
1768
		}
1785
		}
1769
		break;
1786
		break;
1770
1787

Return to bug 3379