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

Collapse All | Expand All

(-)bin/dd/args.c (-38 / +18 lines)
Lines 186-231 Link Here
186
static void
186
static void
187
f_bs(char *arg)
187
f_bs(char *arg)
188
{
188
{
189
	uintmax_t res;
189
	in.dbsz = out.dbsz = get_num(arg);
190
190
	if (in.dbsz < 1 || out.dbsz < 1)
191
	res = get_num(arg);
191
		errx(1, "bs must be between 1 and %ju", (uintmax_t)-1);
192
	if (res < 1 || res > SSIZE_MAX)
193
		errx(1, "bs must be between 1 and %jd", (intmax_t)SSIZE_MAX);
194
	in.dbsz = out.dbsz = (size_t)res;
195
}
192
}
196
193
197
static void
194
static void
198
f_cbs(char *arg)
195
f_cbs(char *arg)
199
{
196
{
200
	uintmax_t res;
197
	cbsz = get_num(arg);
201
198
	if (cbsz < 1)
202
	res = get_num(arg);
199
		errx(1, "cbs must be between 1 and %ju", (uintmax_t)-1);
203
	if (res < 1 || res > SSIZE_MAX)
204
		errx(1, "cbs must be between 1 and %jd", (intmax_t)SSIZE_MAX);
205
	cbsz = (size_t)res;
206
}
200
}
207
201
208
static void
202
static void
209
f_count(char *arg)
203
f_count(char *arg)
210
{
204
{
211
	intmax_t res;
205
	cpy_cnt = get_num(arg);
212
213
	res = (intmax_t)get_num(arg);
214
	if (res < 0)
215
		errx(1, "count cannot be negative");
216
	if (res == 0)
217
		cpy_cnt = (uintmax_t)-1;
218
	else
219
		cpy_cnt = (uintmax_t)res;
220
}
206
}
221
207
222
static void
208
static void
223
f_files(char *arg)
209
f_files(char *arg)
224
{
210
{
225
226
	files_cnt = get_num(arg);
211
	files_cnt = get_num(arg);
227
	if (files_cnt < 1)
212
	if (files_cnt < 1)
228
		errx(1, "files must be between 1 and %jd", (uintmax_t)-1);
213
		errx(1, "files must be between 1 and %ju", (uintmax_t)-1);
229
}
214
}
230
215
231
static void
216
static void
Lines 241-254 Link Here
241
static void
226
static void
242
f_ibs(char *arg)
227
f_ibs(char *arg)
243
{
228
{
244
	uintmax_t res;
245
246
	if (!(ddflags & C_BS)) {
229
	if (!(ddflags & C_BS)) {
247
		res = get_num(arg);
230
		in.dbsz = get_num(arg);
248
		if (res < 1 || res > SSIZE_MAX)
231
		if (in.dbsz < 1)
249
			errx(1, "ibs must be between 1 and %jd",
232
			errx(1, "ibs must be between 1 and %ju", (uintmax_t)-1);
250
			    (intmax_t)SSIZE_MAX);
251
		in.dbsz = (size_t)res;
252
	}
233
	}
253
}
234
}
254
235
Lines 262-275 Link Here
262
static void
243
static void
263
f_obs(char *arg)
244
f_obs(char *arg)
264
{
245
{
265
	uintmax_t res;
266
267
	if (!(ddflags & C_BS)) {
246
	if (!(ddflags & C_BS)) {
268
		res = get_num(arg);
247
		out.dbsz = get_num(arg);
269
		if (res < 1 || res > SSIZE_MAX)
248
		if (out.dbsz < 1)
270
			errx(1, "obs must be between 1 and %jd",
249
			errx(1, "obs must be between 1 and %ju", (uintmax_t)-1);
271
			    (intmax_t)SSIZE_MAX);
272
		out.dbsz = (size_t)res;
273
	}
250
	}
274
}
251
}
275
252
Lines 378-388 Link Here
378
	uintmax_t num, mult, prevnum;
355
	uintmax_t num, mult, prevnum;
379
	char *expr;
356
	char *expr;
380
357
358
	if (val[0] == '-')
359
		errx(1, "%s: cannot be negative", oper);
360
381
	errno = 0;
361
	errno = 0;
382
	num = strtouq(val, &expr, 0);
362
	num = strtouq(val, &expr, 0);
383
	if (errno != 0)				/* Overflow or underflow. */
363
	if (errno != 0)				/* Overflow or underflow. */
384
		err(1, "%s", oper);
364
		err(1, "%s", oper);
385
	
365
386
	if (expr == val)			/* No valid digits. */
366
	if (expr == val)			/* No valid digits. */
387
		errx(1, "%s: illegal numeric value", oper);
367
		errx(1, "%s: illegal numeric value", oper);
388
368
(-)bin/dd/dd.c (-2 lines)
Lines 284-291 Link Here
284
284
285
	for (;;) {
285
	for (;;) {
286
		switch (cpy_cnt) {
286
		switch (cpy_cnt) {
287
		case -1:			/* count=0 was specified */
288
			return;
289
		case 0:
287
		case 0:
290
			break;
288
			break;
291
		default:
289
		default:

Return to bug 191263