Deleted Added
full compact
43c43
< "$FreeBSD: head/bin/dd/args.c 51137 1999-09-11 00:02:42Z green $";
---
> "$FreeBSD: head/bin/dd/args.c 51208 1999-09-12 16:51:53Z green $";
70a71
> static off_t get_offset __P((char *));
72c73
< static struct arg {
---
> static const struct arg {
162a164,168
> /*
> * Bail out if the calculation of a file offset would overflow.
> */
> if (in.offset > QUAD_MAX / in.dbsz || out.offset > QUAD_MAX / out.dbsz)
> errx(1, "seek offsets cannot be larger than %qd", QUAD_MAX);
177c183
< quad_t res = get_num(arg);
---
> quad_t res;
179,181c185,188
< if (res < 1 || res > INT_MAX)
< errx(1, "bs must be between 1 and %d", INT_MAX);
< in.dbsz = out.dbsz = (int)res;
---
> res = get_num(arg);
> if (res < 1 || res > SSIZE_MAX)
> errx(1, "bs must be between 1 and %d", SSIZE_MAX);
> in.dbsz = out.dbsz = (size_t)res;
188c195
< quad_t res = get_num(arg);
---
> quad_t res;
190,192c197,200
< if (res < 1 || res > INT_MAX)
< errx(1, "cbs must be between 1 and %d", INT_MAX);
< cbsz = (int)res;
---
> res = get_num(arg);
> if (res < 1 || res > SSIZE_MAX)
> errx(1, "cbs must be between 1 and %d", SSIZE_MAX);
> cbsz = (size_t)res;
204,205d211
< if (cpy_cnt < 0)
< errx(1, "count cannot be negative");
214,215d219
< if (files_cnt < 0)
< errx(1, "files cannot be negative");
221a226
> quad_t res;
224,226c229,230
< quad_t res = get_num(arg);
<
< if (res < 1 || res > INT_MAX)
---
> res = get_num(arg);
> if (res < 1 || res > SSIZE_MAX)
243a248
> quad_t res;
246,250c251,254
< quad_t res = get_num(arg);
<
< if (res < 1 || res > INT_MAX)
< errx(1, "ibs must be between 1 and %d", INT_MAX);
< out.dbsz = (int)res;
---
> res = get_num(arg);
> if (res < 1 || res > SSIZE_MAX)
> errx(1, "obs must be between 1 and %d", SSIZE_MAX);
> out.dbsz = (size_t)res;
267c271
< out.offset = get_num(arg);
---
> out.offset = get_offset(arg);
275c279
< in.offset = get_num(arg);
---
> in.offset = get_offset(arg);
278c282
< static struct conv {
---
> static const struct conv {
281c285
< u_char *ctab;
---
> const u_char *ctab;
309,311c313,315
< if (!(cp = (struct conv *)bsearch(&tmp, clist,
< sizeof(clist)/sizeof(struct conv), sizeof(struct conv),
< c_conv)))
---
> cp = bsearch(&tmp, clist, sizeof(clist) / sizeof(struct conv),
> sizeof(struct conv), c_conv);
> if (cp == NULL)
350c354
< if (errno) /* Overflow or underflow. */
---
> if (errno != 0) /* Overflow or underflow. */
353c357
< if (expr == val) /* Not a valid number */
---
> if (expr == val) /* No valid digits. */
409a414,425
>
> static off_t
> get_offset(val)
> char *val;
> {
> quad_t num;
>
> num = get_num(val);
> if (num > QUAD_MAX || num < 0) /* XXX quad_t != off_t */
> errx(1, "%s: illegal offset", oper); /* Too big/negative. */
> return ((off_t)num);
> }