View | Details | Raw Unified | Return to bug 234885 | Differences between
and this patch

Collapse All | Expand All

(-)b/usr.bin/cmp/cmp.c (-12 / +12 lines)
Lines 120-129 main(int argc, char *argv[]) Link Here
120
	special = 0;
120
	special = 0;
121
	if (strcmp(file1 = argv[0], "-") == 0) {
121
	if (strcmp(file1 = argv[0], "-") == 0) {
122
		special = 1;
122
		special = 1;
123
		fd1 = 0;
123
		fd1 = STDIN_FILENO;
124
		file1 = "stdin";
124
		file1 = "stdin";
125
	}
125
	} else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) {
126
	else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) {
127
		if (!sflag)
126
		if (!sflag)
128
			err(ERR_EXIT, "%s", file1);
127
			err(ERR_EXIT, "%s", file1);
129
		else
128
		else
Lines 134-143 main(int argc, char *argv[]) Link Here
134
			errx(ERR_EXIT,
133
			errx(ERR_EXIT,
135
				"standard input may only be specified once");
134
				"standard input may only be specified once");
136
		special = 1;
135
		special = 1;
137
		fd2 = 0;
136
		fd2 = STDIN_FILENO;
138
		file2 = "stdin";
137
		file2 = "stdin";
139
	}
138
	} else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) {
140
	else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) {
141
		if (!sflag)
139
		if (!sflag)
142
			err(ERR_EXIT, "%s", file2);
140
			err(ERR_EXIT, "%s", file2);
143
		else
141
		else
Lines 175-189 main(int argc, char *argv[]) Link Here
175
	if (caph_fcntls_limit(fd2, fcntls) < 0)
173
	if (caph_fcntls_limit(fd2, fcntls) < 0)
176
		err(ERR_EXIT, "unable to limit fcntls for %s", file2);
174
		err(ERR_EXIT, "unable to limit fcntls for %s", file2);
177
175
178
	if (!special) {
176
	if (!special && fd1 != STDIN_FILENO && fd2 != STDIN_FILENO) {
179
		cap_rights_init(&rights);
177
		cap_rights_init(&rights);
180
		if (caph_rights_limit(STDIN_FILENO, &rights) < 0) {
178
		if (caph_rights_limit(STDIN_FILENO, &rights) < 0)
181
			err(ERR_EXIT, "unable to limit stdio");
179
			err(ERR_EXIT, "unable to limit stdio");
182
		}
183
	}
180
	}
184
181
	if (fd1 != STDOUT_FILENO && fd2 != STDOUT_FILENO &&
185
	if (caph_limit_stdout() == -1 || caph_limit_stderr() == -1)
182
	    fcntl(STDOUT_FILENO, F_GETFL) == 0 && caph_limit_stdout() == -1)
186
		err(ERR_EXIT, "unable to limit stdio");
183
		err(ERR_EXIT, "unable to limit stdout");
184
	if (fd1 != STDERR_FILENO && fd2 != STDERR_FILENO &&
185
	    fcntl(STDERR_FILENO, F_GETFL) == 0 && caph_limit_stderr() == -1)
186
		err(ERR_EXIT, "unable to limit stderr");
187
187
188
	caph_cache_catpages();
188
	caph_cache_catpages();
189
189

Return to bug 234885