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

(-)usr.bin/fortune/fortune/fortune.c (-4 / +5 lines)
Lines 400-410 Link Here
400
			sp = files[i];
400
			sp = files[i];
401
		else {
401
		else {
402
			percent = 0;
402
			percent = 0;
403
			for (sp = files[i]; isdigit((unsigned char)*sp); sp++)
403
			for (sp = files[i]; isdigit((unsigned char)*sp); sp++) {
404
				percent = percent * 10 + *sp - '0';
404
				percent = percent * 10 + *sp - '0';
405
			if (percent > 100) {
405
				if (percent > 100) {
406
				fprintf(stderr, "percentages must be <= 100\n");
406
					fprintf(stderr, "percentages must be <= 100\n");
407
				return (FALSE);
407
					return (FALSE);
408
				}
408
			}
409
			}
409
			if (*sp == '.') {
410
			if (*sp == '.') {
410
				fprintf(stderr, "percentages must be integers\n");
411
				fprintf(stderr, "percentages must be integers\n");
(-)usr.bin/fortune/strfile/strfile.c (-4 / +10 lines)
Lines 295-302 Link Here
295
295
296
	if (*argv) {
296
	if (*argv) {
297
		Infile = *argv;
297
		Infile = *argv;
298
		if (*++argv)
298
		if (*++argv) {
299
			strcpy(Outfile, *argv);
299
			if (strlcpy(Outfile, *argv, sizeof(Outfile)) >= sizeof(Outfile)) {
300
				fprintf(stderr, "output_file path is not valid\n");
301
				exit(EXIT_FAILURE);
302
			}
303
		}
300
	}
304
	}
301
	if (!Infile) {
305
	if (!Infile) {
302
		puts("No input file name");
306
		puts("No input file name");
Lines 303-310 Link Here
303
		usage();
307
		usage();
304
	}
308
	}
305
	if (*Outfile == '\0') {
309
	if (*Outfile == '\0') {
306
		strlcpy(Outfile, Infile, sizeof(Outfile));
310
		if ((size_t)snprintf(Outfile, sizeof(Outfile), "%s.dat", Infile) >= sizeof(Outfile)) {
307
		strlcat(Outfile, ".dat", sizeof(Outfile));
311
			fprintf(stderr, "generated output_file path is not valid\n");
312
			exit(EXIT_FAILURE);
313
		}
308
	}
314
	}
309
}
315
}
310
316

Return to bug 246050