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

(-)usr/src/usr.bin/random/random.c (-2 / +2 lines)
Lines 165-171 Link Here
165
	 * 0 (which has a 1 / denom chance of being true), we select the
165
	 * 0 (which has a 1 / denom chance of being true), we select the
166
	 * line.
166
	 * line.
167
	 */
167
	 */
168
	selected = (arc4random_uniform(denom) == 0);
168
	selected = ((int)(denom * arc4random_uniform(UINT32_MAX) / (UINT32_MAX-1)) == 0);
169
	while ((ch = getchar()) != EOF) {
169
	while ((ch = getchar()) != EOF) {
170
		if (selected)
170
		if (selected)
171
			(void)putchar(ch);
171
			(void)putchar(ch);
Lines 175-181 Link Here
175
				err(2, "stdout");
175
				err(2, "stdout");
176
176
177
			/* Now see if the next line is to be printed. */
177
			/* Now see if the next line is to be printed. */
178
			selected = (arc4random_uniform(denom) == 0);
178
			selected = ((int)(denom * arc4random_uniform(UINT32_MAX) / (UINT32_MAX-1)) == 0);
179
		}
179
		}
180
	}
180
	}
181
	if (ferror(stdin))
181
	if (ferror(stdin))
(-)usr/src/usr.bin/random/randomize_fd.c (-1 / +1 lines)
Lines 218-224 Link Here
218
				if (n->cp == NULL)
218
				if (n->cp == NULL)
219
					break;
219
					break;
220
220
221
				if (arc4random_uniform(denom) == 0) {
221
				if ((int)(denom * arc4random_uniform(UINT32_MAX) / (UINT32_MAX-1)) == 0) {
222
					ret = printf("%.*s",
222
					ret = printf("%.*s",
223
						(int)n->len - 1, n->cp);
223
						(int)n->len - 1, n->cp);
224
					if (ret < 0)
224
					if (ret < 0)

Return to bug 244139